![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Is it a good idea to have two tables with the same primary key? For example, I have one table which has "QID" as its primary key - this table contains fields which are almost always use for each record. I also have a second table, but the difference is that the fields only occasionally get used. Obviously it is inefficient to have all these secondary fields in the same table as the always-used fields, so I have created a second table with the same QID as PK in order to represent the 1 to 0...1 relationship between the tables. |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Using normalization correctly, you should almost never have 2 tables with the same primary key .I say almost because I'm sure someone can come up with an unusual situation to have one. But as a rule, this should not happen. |
|
As far as putting in seldom used field in the same table, that should not effect your effecieny at all. Just try avoiding: SELECT * FROM table Instead, list only the fields you need in each situation. If anything, having 2 tables with the same key will decrease your effecieny because both table have to maintain the same primary key index and you'll have to setup up additional RI between them. |
|
In short, put all related fields, which relate to each other in a 1-1 relationship, in the same table. |
#5
| |||
| |||
|
|
Is it a good idea to have two tables with the same primary key? For example, I have one table which has "QID" as its primary key - |
|
this table contains fields which are almost always use for each record. I also have a second table, but the difference is that the fields only occasionally get used. Obviously it is inefficient to have all these secondary fields in the same table as the always-used fields, so I have created a second table with the same QID as PK in order to represent the 1 to 0...1 relationship between the tables. |
![]() |
| Thread Tools | |
| Display Modes | |
| |