You are on page 1of 4

NAME: Sayali Milind Deo.

SEAT NO.:704163
LAB1 DBMS (External Practical Exam)

2) Create database using following schema . Apply given Interity Constraint &
answer the following querues using SQL .
(fill up database with at least 05 records in each table)
Doctor(Did,Dname,Daddress,qualification)
PATIANTMASTER(Pcode,Pname,age gender.bloodgroup,Did)
ADMITTEDPATIENT(Pcode,Entry_date,discharge_date,wardno.,disease)
Integrity Constraint:
 The values of any attribute should not null.
 Gender value should beM(male) or F(female)

Queries:
A) Find the details of doctors who are tranning the patient of ward no. 3.

Answer:
Create database db1
CREATE TABLE Doctor(
Did int primary key
Dnmae varchar(30) NOT NULL
Daddress varchar(30) NOT NULL
qualification varchar(30) NOT NULLL
insert into Doctor values
(1,’sayali Deo’,’pachora’,’MD’),
(2,’Aboli Wani’,’pune’,’MBBS’),
(3,’Radha Pathak’,’jalgaon’,’MD Gynac’),
(4,’Mansi Deo’,’palghar’,’MD’),
(5,’Dhanu Varma ’,’pachora’,’BAMS’);
Select*from doctor
Did Dname Daddress qualification
1 sayali Deo Pachora MD
2 Aboli Wani Pune MBBS
3 Radha jalgaon MD Gynac
Pathak
4 Mansi Deo Palghar MD
5 Dhanu pachora BAMS
Varma

CREATE TABLE PATIENTMASTER(


Pcode int primary key
Pnmae varchar(30) NOT NULL
Paddress varchar(30) NOT NULL
age int NOT NULLL
gender char check(gender ‘m’, ‘f’)
bloodgroup varchar(30)
Did reference Doctor(id)
insert into PATIENTMASTER values
1,’Nachi Deo’,’pachora’,15’,’m’AB+’,2),
(2,’Sansu Wani’,’pune’,’22,’f’,’O’,3),
(3,’Soham Pathak’,’jalgaon’, 35,’m’,’B+’,3),
(4,’Shreyash Deo’,’palghar’,’29,’m’,’B-’,5),
(5,’Trupti Varma ’,’pachora’,55,’f’,’A+’,1);
Select*ftom PATIENTMASTER
Pcode Pname Padd age Gender bloodgroup Did
1 ’Nachi ’pachora’ 15 M AB+ 2
Deo’
2 ’Sansu ’pune’ ’22 F O’ 3
Wani’
3 ’Soham ’jalgaon’ 35 M ’B+’ 3
Pathak’
4 ’Shreyash ’palghar’ ’29 M ’B-’ 5
Deo’
5 ’Trupti ’pachora’ 55 F ’A+’ 1
Varma ’

CREATE TABLE ADMITPATIENT (


Pcode int referances,
PATIENTMASTER(Pcode),
Entery_date date NOT NULL,
Discharge _date NOT NULL,
wardno int NOT NULL,
Dises varchar(30) NOT NULL;
Inset into ADMITTEPATIENT values
(1,’01/11,2020’,’15/11/2020’,3,’covid19’),
(2,’26/03/2021’,’27/03/2021’,2,’fracture’),
(3,’26/04/2021’,’26/04/2021’,2,’hight BP’),
(4,’10/05/2020’,’10/05/2020’,4,’maleria’),
(5,’21/11/2020’,’27/11/2020’,5,’dengu’),
Select*From ADMITEDPATIENT
Pcode Entry-date ward disease
Discharge_date Discharge_date no
1 01/11,2020 15/11/2020 3 covid19
2 26/03/2021 27/03/2021 2 Fracture
3 26/04/2021 26/04/2021 2 hight BP
4 10/05/2020 10/05/2020 4 Malaria
5 21/11/2020 27/11/2020 5 Dengu

Answer of Query is:


SELECT*FROM PATIENTMASTER
WHERE
Pcode in (Pcode in ADMITEDPATIENT
WHERE
wardno is 3
Result:
Pcode Pname Wardno Did Dname Dadd Qualification
1 Nachi 3 2 Sayali pachora MD
Deo Deo

You might also like