0% found this document useful (0 votes)
2 views

DBMS_8(SQL)

The document discusses constraints in a Database Management System (DBMS) and their application in SQL, including how to define them during table creation or alteration. It also explains different types of keys used to uniquely identify rows in a database, such as Super Key, Candidate Key, Primary Key, Alternate Key, Unique Key, and Foreign Key. Examples of employee data illustrate the use of these keys and constraints.

Uploaded by

hirshah8523
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

DBMS_8(SQL)

The document discusses constraints in a Database Management System (DBMS) and their application in SQL, including how to define them during table creation or alteration. It also explains different types of keys used to uniquely identify rows in a database, such as Super Key, Candidate Key, Primary Key, Alternate Key, Unique Key, and Foreign Key. Examples of employee data illustrate the use of these keys and constraints.

Uploaded by

hirshah8523
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

DBMS - RELATIONAL

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

Emp_id Emp_name Emp_Aadhar Emp_Sal Emp_Contact Emp_Email

101 HARI 000000000000 45000 123456 [email protected]

102 RAMU 111111111111 50000 672447 NULL

103 HARI 222222222222 43000 NULL [email protected]


Keys in DBMS
Emp_id Emp_name Dept_id

101 HARI 00

102 RAMU 11

103 HARI 22
Dept_id Dept_name Project

101 HARI abc

102 RAMU pqr

103 HARI xyz

You might also like