![]() Think of the term “foreign key” as saying, it’s the key (the unique identifier) for getting a certain record from a foreign table (another table that’s not the table in question).For a given book, if you try and put an ID in the thor_id column that doesn’t correspond to any author in the authors table, the database won’t let you. This foreign-key constraint ensures that the ID stored in the thor_id column, actually points to a specific record on the authors table.We add a FOREIGN KEY constraint to the thor_id column, which tells the database that this column should contain the identifier of a record on the authors table.We add an important column on the books table, say thor_id which will be for storing the identifier of a specific record on the authors table.If you try and create a record and give it an ID that’s already in use, the database won’t let you. This primary-key constraint ensures that multiple records can’t have the same ID. ![]() We add a PRIMARY KEY constraint to this id column to tell the database that it will be what uniquely identifies a record on each table.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |