What are constraints in DDL

By vivek kumar in 22 Jul 2024 | 07:54 pm
vivek kumar

vivek kumar

Student
Posts: 552
Member since: 20 Jul 2024

What are constraints in DDL 

22 Jul 2024 | 07:54 pm
0 Likes
Prince

Prince

Student
Posts: 557
Member since: 20 Jul 2024

In Data Definition Language (DDL), constraints are rules applied to database columns or tables to ensure data integrity and consistency. Key types of constraints include:


1. **Primary Key:** Ensures each row in a table is uniquely identified by one or more columns. No duplicate or null values are allowed.


2. **Foreign Key:** Establishes a link between columns in different tables. It ensures that values in a column (or a set of columns) match values in the primary key of another table, maintaining referential integrity.


3. **Unique:** Guarantees that all values in a column (or a set of columns) are unique across the table, preventing duplicate entries.


4. **Not Null:** Ensures that a column cannot have null values, requiring that each row must contain a value for that column.


5. **Check:** Defines a condition that must be met for the data to be inserted or updated in a column. For example, a check constraint might ensure that a numeric column only contains positive values.


Constraints are essential for maintaining data quality and enforcing business rules within a database.

22 Jul 2024 | 10:49 pm
0 Likes

Report

Please describe about the report short and clearly.