Constraints

  • Primary Key: A constraint that uniquely identifies each row in a table. It ensures that no two rows can have the same value in the primary key column(s). A table can have only one primary key.
  • Foreign Key: This constraint establishes a link between two tables. A foreign key in one table points to a primary key in another, ensuring referential integrity. It prevents actions that would leave orphaned records in the referencing table.
  • Unique Constraint: Ensures all values in a specified column are unique across the table, preventing duplicate entries. Unlike primary keys, a table can have multiple unique constraints.
  • Check Constraint: Validates the data in a column against a specific condition. It can be used to enforce rules, such as ensuring that a salary is greater than zero.
  • Not Null: A constraint that prevents NULL values from being inserted into a column, ensuring that every row must have a value for that column.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *