DBMS_8(SQL)
DBMS_8(SQL)
MODEL
Constraints in DBMS
Constraints in DBMS
• SQL constraints are used to specify rules for data in a
table.
• Constraints can be specified when the table is created
with the CREATE TABLE statement, or after the
table is created with the ALTER TABLE statement.
Constraints in DBMS
• Syntax1:
CREATE TABLE table_name (
column1 datatype constraint,
column2 datatype constraint,
column3 datatype constraint,);
• Syntax2:
ALTER TABLE table_name1 ADD
constraint(attribute name) REFERENCES
table_name2(attribute name) ;
Keys in DBMS
• Key is an attribute/ set of attributes to identify rows
uniquely.
• Super Key
• Candidate Key(Minimal set of super key)
• Primary Key(any key from candidate key + Not
NULL)
• Alternate Key(all candidate keys except primary key)
• Unique Key(similar to primary key having NULL)
• Foreign Key(used to relate one table with another
table)
Keys in DBMS
101 HARI 00
102 RAMU 11
103 HARI 22
Dept_id Dept_name Project