Skip to content
- Constraints are the rules given to the table for a particular column.
- UNIQUE CONSTRAINTS: A column shouldn’t contain repeated and duplicated values.
- NOT NULL CONSTRAINTS: A column shouldn’t contain null.
- CHECK CONSTRAINTS:
- It is an extra validation given to a column.
- If the condition is satisfied, the results are true or false.
- condition: CHECK(LENGTH(COL_NAME)=SIZE)
- PRIMARY KEY CONSTRAINTS:
- A column is uniquely identified to be a primary key.
- Characteristics of a primary key.
- In a table, we can have only one primary key.
- The primary key will not accept a null.
- The primary key will not accept repeated and duplicated values.
- The primary key is a combination of unique and not null constraints.
- The primary key is not mandatory, but highly recommended.
- FOREIGN KEY:
- A foreign key is a constraint used to establish a connection between multiple tables.
- Characteristics of the foreign key.
- In a table, we can have multiple foreign keys.
- Foreign key accepts null.
- Foreign keys accept repeated and duplicated values.
- A foreign key is not a combination of unique and not null.
- To be a foreign key, that foreign key must be a primary key of its table.