Entity integrity makes sure that there aren’t any duplicate records in the database and that each record’s identifying field is distinct and never null. The primary tenet of entity integrity is the existence of the Primary Key. It cannot be a relational table if an entity key is not present. According to the relational model, each relation (or table) must have a primary key (abbreviated PK) that allows each row of the same relation to be identified by its content, that is, by a distinct and minimal value.
Example:
CREATE TABLE tbStudentDetails(
—-iStudentID INT PRIMARY KEY,
—-vcStudentName VARCHAR(40),
—-tiGroupID TINYINT REFERENCES stbGroups(tiGroupID),
—-sdtApplicationDate SMALLDATETIME DEFAULT ‘2016-06-13’,
—-sdtJoinDate SMALLDATETIME,
—-vcFatherName VARCHAR(40) NULL, vcAddress1 VARCHAR(20,
—-vcAddress2 VARCHAR(20) NULL, vcCity VARCHAR(20),
—-bActive BIT NOT NULL DEFAULT 1)
GO
Happy learning..!!!
One comment