Web design tools - Figure 3-22: A foreign key is used to
Figure 3-22: A foreign key is used to link back to the primary key of a parent table. There will be more explanation of the how and why of primary and foreign keys Chapter 4. At this point, simply remember that a primary key uniquely identifies each record in a table. A foreign key is a copy of the primary key copied from a parent table, establishing a relationship between parent and child tables. A unique key simply ensures the uniqueness of a value within a table. Try It Out Creating Some Simple Tables Figure 3-23 shows some data. Do the following exercise: 1. Create two related tables linked by a one-to-many relationship. 2. Assign a primary key field in each table. 3. Assign a foreign key field in one table. 1 2 3 4 5 6 7 Orson Scott Card James Blish Isaac Azimov Larry Niven Jerry Pournelle William Shakespeare Kurt Vonnegut AUTHOR_ID NAME 1 2 3 4 5 6 7 AUTHOR_ID 1 2 3 4 5 6 7 Cities in Flight A case of Conscience Foundation Second Foundation Foundation and Empire Foundation s Edge Prelude to Foundation 4 7 Lucifer s Hammer Footfall Ringworld The Complete Works of Shakespeare PUBLICATION_ID NAME 11 12 Jerry Pournelle Jerry Pournelle COAUTHOR 5 5 COAUTHOR_ID PUBLICATION_ID Footfall Lucifer s Hammer TITLE 4 4 9 10 9 10 Author author_id name Publication publication_id subject_id (FK) author_id (FK) title CoAuthor coauthor_id (FK) publication_id (FK) 61 Database Modeling Building Blocks
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.