A FOREIGN KEY as a relationships in one table points to a PRIMARY KEY in another table.
we will create a CREATE TABLE script for these tables:
DtlPermission:
MstGroup:
The FOREIGN KEY constraint prevents that invalid data from being inserted into the foreign key column.
we will create a CREATE TABLE script for these tables:
DtlPermission:
CREATE TABLE DtlPermission
(
Member_Id int NULL,
GroupId int NULL,
Can_View_Sale_Lead bit NULL,
Can_View_Buy_Lead bit NULL,
Can_Sale bit NULL,
Can_Buy bit NULL,
Up_To_Date date NULL
) ON [PRIMARY]
(
Member_Id int NULL,
GroupId int NULL,
Can_View_Sale_Lead bit NULL,
Can_View_Buy_Lead bit NULL,
Can_Sale bit NULL,
Can_Buy bit NULL,
Up_To_Date date NULL
) ON [PRIMARY]
MstGroup:
CREATE TABLE MstGroup
(
GroupId int NOT NULL FOREIGN KEY REFERENCES DtlPermission(GroupId), Groupname nvarchar(100) NULL
)
(
GroupId int NOT NULL FOREIGN KEY REFERENCES DtlPermission(GroupId), Groupname nvarchar(100) NULL
)
The FOREIGN KEY constraint prevents that invalid data from being inserted into the foreign key column.
Post a Comment