Domain integrity assures that every data in a field contains legitimate values, is established by the permitted values of an attribute. Data types such as decimal, character, and integer as well as the maximum length for data are what make up domain integrity.
Normally, we would define what kind of data and how much data the column should store during the table creation. For instance, the column Student Name typically contains string (text) values, the column “Date of payment” typically contains data in date format, and the column “Student Id” typically contains numeric values (integer data type). By specifying the data type, we are instructing the SQL Server not to store the data in any other data type than that which is given.
This rule is called domain integrity constraint.
Example:
CREATE TABLE tbStudentDetails(
—-iStudentID INT,
—-vcStudentName VARCHAR(40),
—-tiGroupID TINYINT,
—-sdtApplicationDate SMALLDATETIME,
—-sdtJoinDate SMALLDATETIME,
—-vcFatherName VARCHAR(40),
—-vcAddress1 VARCHAR(20),
—-vcAddress2 VARCHAR(20),
—-vcCity VARCHAR(20),
—-bActive BIT)
GO
Happy learning!!!
One comment