Ad Code

Foreign key and Primary key

What is the procedure to set foreign key and primary key on table in sql??



 you can set a primary key with a key word "Primary Key" like:

CREATE TABLE Member (
MemberId integer primary key NOT NULL,
FirstName nvarchar(50),
LastName nvarchar(50),
DateOfBirth datetime,
City varchar(75),
ZipCode varchar(12),
Email varchar(200),
DateOfJoining datetime
                                           );
and a foreign key with the help of this syntax:

CREATE TABLE Attendance (
MeetingDate datetime,
Location varchar(200),
MemberAttended char(1),
MemberId integer foreign key references Member(MemberId),
                                               );
Reactions

Post a Comment

0 Comments