开发者

MySQL/PHP Database Normalisation

Im working amongst a group of fellow 开发者_如何学运维students creating relational mysql database to be used in conjunction with php.

We are attempting to normalise the database and are differing in opinion. When normalising and creating a new table two of the group, myself included feel the best practice is for the foreign key to be left behind in the existing table as the unique identifier in the new table becomes the new PK.

The remainder of the group have been taught/feel this should be implemented the other way, i.e. the primary key is left behind.

Could it be the case as long as a relationship is present it will do the job, or is it the case one method is correct over the other.

Thanks in advance

Gary


This depends on what you are doing. When you are removing a partial dependency then the rule is:

   r = (A, B, C, D)
   where
      A and B makes a composite primary key and
      C is dependent on A 
   then
      r1 = (A, C)
      r2 = (A, B, D)
  

If you are removing a Transitive dependency then:

     r = (A, B, C)
     where A is the primary key and C is dependent on B then

     r1 = (A, B)
     r2 = (B, C)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜