Professional Documents
Culture Documents
AFC Assignment
AFC Assignment
name), complete all the entities with suitable attributes together with assigned primary
key.
1) Table: Person
2) Table: Registration
3) Table: Vaccination
4) Table: Vaccine
b) Identify ALL relationships, cardinality, and/or participation for each identified entity.
One person shall do one registration.
One registration is to have one vaccination.
One vaccination session has many vaccines.
c) Draw an Entity Relationship Diagram (ERD) by clearly stating the relationships between
entities, cardinalities and attributes with correct notation.
d) Based on ERD created in (c), convert it into relational schema. State the primary key and
foreign key for each relational schema (relations).
e) Create all relevant relations (tables) based on relational schema in (d). Choose appropriate
data types for each attribute. Indicate the primary key and foreign key in each relation
(table) created.
NRIC INT,
MOBILE_NO INT,
);
SELECT * FROM PERSON;
DOSE INT,
FIRSTDOSE_DATE DATE,
SECONDDOSE_DATE DATE,
);
FIRSTDOSE_DATETIME DATETIME,
SECONDDOSE_DATETIME DATE,
VAC_STATUS TEXT,
);
MANUFAC_COUNTRY TEXT,
f) Produce sample records for each relation (table) that observes the relational integrity
rules. FIVE records per relations are enough.
Insert record
Person table
insert into person values ('SJ01','Harry Potter','958011049899','LOT 48, TAMAN SRI WANGI, KUALA
LUMPUR','01189945003','harrypotter@gmail.com');
insert into person values ('SJ02','Chris Brown','9489200988349','LOT 50, TAMAN BUNGA RAYA,
KUALA LUMPUR','0198348433','cbrown98@gmail.com');
insert into person values ('SJ03','Ahmad Kamal','920032137899','LOT 90, TAMAN BUNGA ORKID,
KUALA LUMPUR','0158903450','a_kamalz@gmail.com');
insert into person values ('SJ04','Mira Filzah','960923108890','LOT 60, TAMAN BUNGA MATAHARI,
KUALA LUMPUR','0178904598','mfilzah@gmail.com');
insert into person values ('SJ05','Lee Chong Wu','900528068324','LOT 83, TAMAN SRI KEMBANGAN,
KUALA LUMPUR','0125468992','leechongwu@gmail.com');
Registration table
Vaccination table
Vaccine table
g) Then, produce FIVE SQL queries that can be used to manipulate the data from each
relation and show ALL the results from each of the queries. (The queries should include a
simple query, query for sorting results, aggregate function, sub-queries and query to alter
the existing tables.)
5 QUERIES
b) QUERY FOR SORTING RESULTS: select * from person order by FULLNAME ASC;
Before:
After: