You are on page 1of 10

nd

BSc CS 2 Year Sem III


Database Management System

DBMS – E1UA320B
Rohit Verma – 22SCSE1560001

Submitted To Submitted By
Mr. Shobhit Kumar Rohit Verma
Experiment - 4
Implement various types of Integrity constraints on databases.

Integrity constraints are a set of rules. It is used to maintain the quality of information.

There are four types of Integrity constraints in DBMS -

1. Domain Constraints - Domain constraints can be defined as the definition of a


valid set of values for an attribute.

2. Entity Integrity Constraints – The entity integrity constraint states that primary
key value can't be null.

3. Refrential Integrity Constraints - A referential integrity constraint is specified


between two tables. In the Referential integrity constraints, if a foreign key in Table 1
refers to the Primary Key of Table 2, then every value of the Foreign Key in Table 1
must be null or be available in Table 2.
4. Key Constraints - Keys are the entity set that is used to identify an entity within its
entity set uniquely.
Experiment – 5

Single row function and group function.


1. Single Row Function

2. Group By Function
Experiment - 6
Perform various type of set operation in MySQL.
Queries –
use univarsal;
create table table1(
id int primary key,
name varchar(100),
age int,
add_no varchar(20)
);

create table table2(


id int primary key,
name varchar(100),
age int,
add_no varchar(20),
mobile_no long
);

insert into table1 values


(100,"Rohan",20,"scse1560002"),
(101,"Rohit",19,"scse1560001"),
(102,"Rahul",20,"scse1550005"),
(103,"Ranveer",35,"scse1560021"),
(104,"Roshan",40,"scse1560013")
;
insert into table2 values
(100,"Rohan",20,"scse1560002" , 9911999393),
(101,"Rohit",19,"scse1560001" , 929499833),
(102,"Rahul",20,"scse1550005",28362936),
(103,"Ranveer",35,"scse1560021",83462578),
(104,"Roshan",40,"scse1560013",563265985)
(105,"Raghavr",35,"scse1560043",834625578),
(106,"Ronit",50,"scse1560045",5632657885);

1. Union

2. Intersect
3. Except
Experiment 7
Consider the following schema:
Suppliers(sid,integer, sname: string, address: string)
Parts(pid, integer, pname: string, color: string)
Catalog(sid,integer, pid: integer, cost: real)
1. Find the names of suppliers who supply some red part.
2. Find the sids of suppliers who supply some red or green part.
3. Find the sids of suppliers who supply some red part
4. Find the sids of suppliers who supply some red part and some green part.
5. Find the sids of suppliers who supply every part.

1. Find the names of suppliers who supply some red part.

2. Find the sids of suppliers who supply some red or green part.
3. Find the sids of suppliers who supply some red part

4. Find the sids of suppliers who supply some red part and some green part.

As there is no one who supply both Red and Green part.

5. Find the sids of suppliers who supply every part.

As there is not even a single supplier who supply every color part.

You might also like