Connecting Tech Pros Worldwide Forums | Help | Site Map

Question about DB normalisation

mikek12004's Avatar
Familiar Sight
 
Join Date: Sep 2008
Location: Athens, Greece
Posts: 188
#1: Jun 18 '09
I have a table for categories (id->the primary key, and name) and I want to add another column parent (one category might be inside another) with the id's range of values so in fact parent will be a foreign key of the id right?Can I declare a foreign key of a primary key in the same table as that primary key or it is better make a seperate table for the relationships between categories? (lately been reading about db normalisation and wandering which the right thing to do)
PS any good tutorials on DB normalisation ?

Member
 
Join Date: Dec 2007
Posts: 47
#2: Jun 30 '09

re: Question about DB normalisation


I got the most from these tutorials.

http://www.keithjbrown.co.uk/vworks/mysql/mysql_p7.php

But normalisation has to be one of the hardest things involved in designing a website. Especially with around 10-20 tables and hundreds of columns. I just dont seem to be able to learn it. ;p just read it over and over and it sort of gets a little clearer but never clear. Good luck.
Member
 
Join Date: Aug 2007
Posts: 119
#3: Jul 4 '09

re: Question about DB normalisation


No, you can't create a foreign key in its own table. To be foreign, it must be the primary key in another table. This is why you call it foreign. Otherwise I think you would have to call it a "native" key. ;-)
Reply


Similar MySQL Database bytes