Search the Community
Showing results for tags '1nf'.
-
Hi! This is not a question as such, I am mainly looking for somebody to tell me whether I am on the right track or way off the mark. I am currently working through the MySQL chapters, in particular Normalization. i just want to check if I have understood everything corrctly so far. Say I am creating a "language skills database" for an office, where all of the staff speak one or more foreign languages. Staff_id (PRIMARY KEY) first_name last_name email telephone number start_date language The way I understand normalization, I would need to first create table for the staff, removing the language column as each member of staff my speak more than one foreign language (French, German and Spanish for instance) which would be in violation of 1NF (i.e. atomicity) ie.: Staff_id (PRIMARY KEY) first_name last_name start_date This table would be in 1NF, as each entry has a Primary key, each field is atomic and each record will appear only once. I would then have to create a "Language Skills" , i.e. lang_id (PRIMARY KEY) language Again, I understand that this table would be 1NF. The Relationship between the two tables is currently M:M i.e. one memeber of stafff can speak mutiple languages, and each language (French for instance) may be spoken by many members of staff. I would therefore require a thrid table (a link / intermediary table) along the following lines: Staff_id (FOREIGN KEY) lang_id (FOREIGN KEY) whereby the link from the staff table to the link table is 1:M and the link from the Languages table to the link table is also 1:M So then by now my database is 1NF (no listed fields, and each table has a primary key) and 2NF (any columns that would contain duplicated data - ie. the languages spoken by the staff - have been slipt off into a new table - i.e. the languages table) Does this sound about right? All comments and tips will be very much appreciated. Thanks LF