| Start |
|---|
| Creating a table with a foreign key In this example we have an existing table, This table contains a primary key We will add a new table in order to store the powers of each super hero: The column |
| Foreign Keys explained Foreign Keys constraints ensure data integrity, by enforcing that values in one table must match values in another table. An example of where a foreign key is required is: In a university, a course must belong to a department. Code for the this scenario is: Insert values with the following statement: The following table will contain the information of the subjects offered by the Computer science branch: (The data type of the Foreign Key must match the datatype of the referenced key.) The Foreign Key constraint on the column the database will raise a Foreign Key violation error, because then the database allows these values. A few tips for using Foreign Keys
|
Read Article
https://develop.horje.com/learn/1434/reference