DEV Community

FatimaAlam1234
FatimaAlam1234

Posted on

SQL - Data Integrity and Security

Entity Integrity

Entity integrity ensures that there are no duplicate rows in a table. This is often managed with the help of the primary key.

CREATE TABLE Employee (
  EmployeeID int NOT NULL,
  LastName varchar(255),
  FirstName varchar(255),
  Age int,
  PRIMARY KEY (EmployeeID)
);
Enter fullscreen mode Exit fullscreen mode

Domain Integrity

Domain Integrity enforces valid entries for a given column by restricting the type, the format, or the range of possible values.

Referential Integrity

Referential integrity ensures that relationships between tables remain consistent. More specifically, that a foreign key in one table must always refer to the primary key in another table.

User-Defined Integrity

Top comments (0)