1 message in com.mysql.lists.mysqlunsure of performance vs. replication...
FromSent OnAttachments
Jim Matzdorff19 Jul 2001 14:52 
Subject:unsure of performance vs. replication of data...
From:Jim Matzdorff (jma@redback.com)
Date:07/19/2001 02:52:20 PM
List:com.mysql.lists.mysql

I have a general DB question, but since I'm using MySQL, I figure one of our friendly listreaders might be able to help me out.

I have 4 tables, say "table1-table4", and I need to get some data from table4 which relies on some values from table1. However, the only way I can get those table1 values, is by going through tables 2 and 3. So... the query, in essence, looks like:

select table4.id from table1,table2,table3,table4 where table4.table3_id = table3.id and table3.table2_id = table2.id and table2.table1_id = table1.id and table1.value = "VALUEIMLOOKINGFOR".

now -- the reasons i have 4 tables such as this is each table holds a key peice of data.

*BUT*, there's nothing from preventing me from adding a column to table4 called "table1_id" and doing something like

select table4.id from table1,table4 where table4.table1_id = table1.id and table1.value = "VALUEIMLOOKINGFOR"

my questions falls on the replication of data issue (and understand, a DB Guru I am not, but I've read Paul DeBois book and think i have a pretty fair handle of things). Anyway, since I can infer the data without having to replicate anything (ie: the first query) is it good DB practice that, if you are making this type of query, to go ahead of be able to reference the data directly (ie: the second query), even though table4 would, in essence, be storing the "table1_id" when it could be gotten via a query anyway?

Am I making myself clear? I am trying to determine when it's ok to have extra columns the duplicate data you can get elsewhere but would make a query potentially faster (i believe) but the tables larger?

If anyone can point me elsewhere as well...

--jim