Tutorial by Examples

In this example we have an existing table, SuperHeros. This table contains a primary key ID. We will add a new table in order to store the powers of each super hero: CREATE TABLE HeroPowers ( ID int NOT NULL PRIMARY KEY, Name nvarchar(MAX) NOT NULL, HeroId int REFERENCES SuperHero...
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: CREATE TABLE Department ( Dept_Code...

Page 1 of 1