Database Project

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

DATABASE PROJECT

PRESENTED BY

NAME: Kush Rajput

ADM NO: 18ZAD103655


QUESTION A

a) Create a conceptual ER diagram for the above description (8 marks)

1 M
Herbal Medic Patient
Attends

1 1

Give Receive

M M

Herbal Prescription Medicine

O
O

Date Patient Medic Herbs Name Unit Price per Unit


QUESTION B

b) Create a relational schema from the conceptual ER diagram (5 marks)


QUESTION C

c) State any two assumptions you have made in drawing the ER diagram above (2 marks)

 A patient can have multiple herbal medicines.

 Medical centre can offer accommodation to more than one patient.

QUESTION D

d) Create relations to hold the data for the above database and enter five records in each
table. (4 marks)

QUESTION E

e) Write an sql statement to display a list of patients and the name of the medics who have
attended to them (4 marks) .

CREATE TABLE Patients(


patientsId varchar(2) PRIMARY KEY,
patientsName varchar(10)
);

INSERT INTO patient VALUES (‘Celestine’,’2234’);


INSERT INTO patient VALUES (‘John’,’2235’);
INSERT INTO patient VALUES (‘Maria’,’2236’);
INSERT INTO patient VALUES (‘Brian’,’2237’);
INSERT INTO patient VALUES (‘James’,’2238’);
QUESTION F
f) Write an sql statement to display a list of patients and any herbal medicines that have been
prescribed to them, ordered by patient name. (5 marks)

CREATE TABLE HerbalMedicine (


herbalMedicineId varchar(2) PRIMARY KEY,
herbalName varchar(10),
unit varchar(10),
pricePerUnit varchar(10)
);

INSERT INTO herbalmedicine VALUES (‘Chamomile’, ’AA21’, ’100’, 400);


INSERT INTO herbal_medicine VALUES (‘Feverfew’,’AA22’,’12’, 250);
INSERT INTO herbal_medicine VALUES (‘Ginger’, ’AA23’, ’50’, 100);
INSERT INTO herbal medicine VALUES (‘Ginseng’, ’AA24’, ’33’, 600);
INSERT INTO herbal_medicine VALUES (‘Coneflower’, ’AA25’, ’67’, 800);
QUESTION G
g) Write an sql statement to display a list of herbal medicines that cost more than 200
shillings (2 marks)

SELECT Patient_Name, Medic_Name FROM prescription


SELECT Patient_Name, Herb_Name FROM prescription ORDER BY Patient Name
SELECT Herb_name, Price_per_unit FROM herbal medicine WHERE Price_per_unit > 200
CREATE TABLE herbal medic (
Medic name varchar(255),
Medic ID varchar(10),
);

INSERT INTO herbal_medic VALUES (‘Dr. Kilonzo’, ‘1122’);


INSERT INTO herbal_medic VALUES (‘Dr. Opiyo’, ’1123’);
INSERT INTO herbal_medic VALUES (‘Dr. Wairimu’, ‘1124’);
INSERT INTO herbal_medic VALUES (‘Dr. Hadid’, ‘1125’);
INSERT INTO herbal_medic VALUES (‘Dr. William’,’1126’);

CREATE TABLE prescription (


Date_treat DATE,
Patient Name varchar(255),
Medic Name varchar(255),
Herb Name varchar(255)
);
INSERT INTO prescription VALUES (‘122019’,’ John’,’ Dr. William’,’ Feverfew’);
INSERT INTO prescription VALUES (‘2352019’,’ Celestine’,’ Dr. Hadid’,’ Chamomile’);
INSERT INTO prescription VALUES (‘1262019’,’ Maria’,’ Dr. Opiyo’,’ Coneflower’);
INSERT INTO prescription VALUES (‘372019’,’ Brian’,’ Dr. Kilonzo’,’ Ginseng’);
INSERT INTO prescription VALUES (‘432019’,’ James’,’ Dr. Wairimu’,’ Ginger’);

You might also like