Database Concepts
Mar 15, 2021
CONSTRAINTS: These are set of rules that we need to follow when entering a data into an table. The constraints are specified when creating a Table or altering a table.
1.) NOT NULL : All values in column are non-empty.
CREATE TABLE STUDENT ( ID int NOT NULL, STUDENT_NAME VARCHAR(250) NOT NULL );
2.) UNIQUE : All values in column are different and unique.
CREATE TABLE STUDENT ( ID int NOT NULL, STUDENT_NAME VARCHAR(250) NOT NULL , CONSTRAINT ID_C UNIQUE(ID));
3.) PRIMARY KEY : Unique and Not Null. A table can have ONE Primary Key, but it can have MANY Unique constraints.
4.) FOREIGN KEY: To maintain integrity of data