Professional Documents
Culture Documents
DBMS Exp-03 Sem-Iii Mumbai University
DBMS Exp-03 Sem-Iii Mumbai University
DBMS Exp-03 Sem-Iii Mumbai University
Roll No. : 63
Division :D
Batch : D3
Day / Session :
Venue : Online
Experiment No. : 03
Title of Experiment : Creating a Database using DDL and apply Integrity Constraints
Date of Conduction :
Max. Marks
Particulars
Marks Obtained
Preparedness and Efforts(PE) 3
Knowledge of tools(KT) 3
Debugging and results(DR) 3
Documentation(DN) 3
Punctuality & Lab Ethics(PL) 3
Total 15
Grades – Meet Expectations (3 Marks), Moderate Expectations (2 Marks), Below Expectations (1 Mark)
I. CREATE DATABASE:
SYNTAX:
INPUT/ EXAMPLE
OUTPUT:
'"l ' , • • (- , t"� \j •'-- ..-� ...
J - ,_, •
,) (.IJ •- c1 -
• - - IL •
� '::.>.t--' ; •..., , .::j ''
J •
I
�) J •• • ' 1 J Ii� ' 1 r I I f (j .. t •• , ♦ •' � �� 0 ') �1 t' \
SYNTAX:
columnl data_type(size),
column2 data_type(size),
column3 data_type(size),
INPUT/EXAMPLE:
Create Table Books
2) DROP:
SYNTAX:
INPUT/EXAMPLE:
3) ALTER
This is used to alter the structure of the database.
SYNTAX:
ALTER TABLE table_name
ADD (Columnname_1 datatype,
Columnname_2 datatype,
Columnnamen datatype)
INPUT/EXAMPLE:
Alter table books
add Author varchar (20) ;
OUTPUT
d Name Pnice Autnor
Disney 100
Harry Potter ul
Donald 400
Constraints in DBMS
Relational constraints are the restrictions imposed on the database contents and
operations. They ensure the correctness of data in the database.
Domain Constraint:
Domain constraint defines the domain or set of values for an attribute.
It specifies that the value taken by the attribute must be the atomic value from
its domain.
SO01 Akshay 0
SO02 Abhishek
SO03 Shashank 20
SO04 Rahul
Here, value 'A' is not allowed since only integer values can be taken by the age
attribute.
INPUT/EXAMPLE:
QUTPUT:
OK
2) Key Constraint:
S001 Akshay 20
SO02 Abhishek
SO05 Shashank 20
S004 Rahul 20
This relation does not satisfy the key constraint as here all the values of primary
key are not unique
INPUT/EXAMPLE:
3) EntityIntegrityConstraint:
Entity integrity constraint specifies that no attribute of primary key must contain a
null value in any relation.
This is because the presence of null value in the primary key violates the uniqueness
property.
sO02 Abhishek
SO03 Shashank
Rahul 20
This relation does not satisfy the entity integrity constraint as here the primary key
contains a NULL value.
INPUT/EXAMPLE:
OUTPUT:
Error 1: could not execute statement due to a constraint failure (19 NOT
NULL constraint failed: Books.ld)
OK
4) ReferentialIntegrity Constraint
This constraint is enforced when a foreign key references the primary key of a relation.
It specifies that all the values taken by the foreign key must either be available in the
relation of the primary key or be null.
cONCLUSION
We have learn different DDL Commands and their uses and different types of Integrity
Constraints in SQL.