0% found this document useful (0 votes)
450 views

Ict200 - Lab Exercise

The document describes a database system for Dr. Jamil Abdullah Optometry Centre. It outlines entities like optometrists, patients, appointments, payments, invoices, and insurance that need to be recorded in the database. It also lists scenarios like an optometrist being scheduled for appointments, a patient making multiple payments, and an insurance company making payments. The solution provides an entity relationship diagram and relational schema for the database along with SQL commands to create the tables.

Uploaded by

Dina Zarifah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
450 views

Ict200 - Lab Exercise

The document describes a database system for Dr. Jamil Abdullah Optometry Centre. It outlines entities like optometrists, patients, appointments, payments, invoices, and insurance that need to be recorded in the database. It also lists scenarios like an optometrist being scheduled for appointments, a patient making multiple payments, and an insurance company making payments. The solution provides an entity relationship diagram and relational schema for the database along with SQL commands to create the tables.

Uploaded by

Dina Zarifah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

12/18/23, 10:26 AM ICT200 - LAB EXERCISE

ICT200 Lab Week 8 (MAR20 C)

Dr. Jamil Abdullah Optometry Centre plans to use a database system to support its
operations. The
optometry Centre currently has four optometrists and is open from Monday to Friday
from 9.00 am to 5.00pm. Given below are the scenarios at the optometry center.

 For an optometrist, their IC number, name, telephone number,


address and room number should be recorded.

 An optometrist can be scheduled for many appointments, but in case


of a new optometrist she/he may not have any appointments at all.

 Each appointment is scheduled with only one optometrist.


Appointment date and time are needed.

 A patient can be scheduled in one or more appointments. One


appointment is scheduled with only one patient. Patient’s detail
such as IC number, name, telephone number and address need to be
kept by the database system.

 An appointment will generate one invoice; and one invoice can be


paid off through several payments. An invoice can be outstanding,
having nothing yet paid on it by all.

 One patient can make many payment, but a single payment is made
by only one patient. Some patients are insured by insurance
company. If they are insured, they can only carry insurance with
one company.

 An insurance company can have many patients carry their policies.

 For a patient that carries insurance, the insurance company will make
payment; each single payment is made by only one insurance
company.

a)Based on the above information, create a complete entity relationship diagram


(ERD) that shows all entities, attributes, relationships and connectivities.

b)List two example of report that can be produced from this database system.

Solution

Entity: RED
Relationship: GREEN
Attribute: BLUE

Relational scheme:

Entity (attribute1,attribute2,attribute3 ….)


Primary Key = underline
Foreign Key = *
Both PK & FK = both underline & *

about:blank 1/5
12/18/23, 10:26 AM ICT200 - LAB EXERCISE

ANSWER :

Optometrist ( optometrist_ICNo, optometrist_name, optometrist_telephoneNo,


optometrist_address and optometrist_roomNo )

Patient ( patient_ICNo, patient_ name, patient_ telephoneNo, patient_ address )

Appointment (patient_name, optometrist_name, appointment_date, appointment_time )

Payment (payment_receiptNo, payment_amount, payment_method )

Insurance (patient_name, patient_ telephoneNo, patient_ address* )

Invoice ( payment_receiptNo, payment_method*,invoice_date )

about:blank 2/5
12/18/23, 10:26 AM ICT200 - LAB EXERCISE

This is a preview
Do you want full access? Go
db2 => create table optometrist(optometrist_ICNo char(12) not null, optometrist_name
varchar(20), optometrist_telephoneNo char(12) notPremium and unlock all
5 pages
null, optometrist_address
varchar(20), optometrist_roomNo char(12) not null, constraint pk_optometrist primary
key(optometrist_ICNo))
Access to all documents
db2 => create table patient(patient_name varchar(20) not null, patient_ICNo char(12)
Getvarchar(20),
not null, patient_telephoneNo char(12) not null, patient_address Unlimited Downloads
constraint
pk_patient primary key(patient_name))
Improve your grades
db2 => create table appointment(patient_name varchar(20) not null, optometrist_name
varchar(20) not null, appointment_date date, appointment_time time)
db2 => alter table appointment add constraint pk_appointment primary
key(patient_name,optometrist_name)
Free Trial
Get 7 days of free
db2 => create table payment(payment_amount char(12) not null, payment_method
varchar(20) not null, payment_receiptNo char(12) not null)
Premium
db2 => alter table payment add constraint pk_payment primary key(payment_method)

db2 => create table invoice(invoice_receiptNo char(12) not null,payment_method


varchar(20) not null, invoice_date date not null)
db2 => alter table invoice add constraint pk_invoice primary key(invoice_receiptNo)
Upload
db2 => alter table invoice add constraint fk1_invoice foreign key(payment_method)
references payment(payment_method)
Share your documents
db2 => create table insurance(patient_name varchar(20) not null, ins_telephoneNo
to unlock
char(12) not null, ins_address varchar(20) not null)
db2 => alter table insurance add constraint pk_insurance primary key(patient_name)

db2 => list tables


db2 => select * from optometrist Already Premium? Log in
db2 => select * from patient
db2 => select * from appointment
db2 => select * from payment
db2 => select * from invoice
db2 => select * from insurance

about:blank 3/5
12/18/23, 10:26 AM ICT200 - LAB EXERCISE

about:blank 4/5
12/18/23, 10:26 AM ICT200 - LAB EXERCISE

about:blank 5/5

You might also like