(Happy) Assignment#1
(Happy) Assignment#1
COMP 122-006
Assignment - 1
Question-01
a) Give an example of three entities that might exist in a database for a medical office, and list
some attributes that would be stored in a table for each entity.
Patient entity:
Attributes: patient name, patient Id, date of birth, gender, address, contact number and email
address.
Doctor entity:
Attributes: doctor name, doctor name, doctor schedule, specialization, qualifications, contact
number, email.
Appointment entity:
Attributes: appoint_Id, Patient_Id, doctor_Id, appoint_date, appoint_time, reason, status,
diagnosis.
b) What is a relationship, and what three types of relationships exist? Give an example of each
of the three types of relationships as per your example of entities in part (a)
Patient entity:
1. One-to-one relationship: Each primary doctor may only have one primary patient, and
each primary patient may only have one primary doctor. In this instance, a foreign key
referencing the doctor object and vice versa would be present in the patient entity.
Doctor entity:
Appointment entity:
b) Every employee in a company is assigned to one department. Every department can contain
many employees.
c) Data for an information technology conference needs to be collected. The conference has a
variety of sessions scheduled over a two-day period. All attendees must register for the sessions
they plan to attend. Some speakers are presenting only one session, whereas others are
handling multiple sessions. Each session has only one speaker.
Question-03
1. Display a list of all data contained in the BOOKS table.
2. List the title only of all books available in inventory, using the BOOKS table.
3. List the title and publication date for each book in the BOOKS table. Use the column
heading “Publication Date” for the Pubdate field.
4. List the customer number for each customer in the CUSTOMERS table, along with the
city and state in which the customer lives.
5. Create a list containing the publisher’s name, the person usually contacted, and the
publisher’s telephone number. Rename the contact column “Contact Person” in the
displayed results.
6. Determine which categories are represented in the current book inventory. List each
category only once.
7. List the customer number from the ORDERS table for each customer who has placed an
order with the bookstore. List each customer number only once.
8. Create a list of each book title stored in the BOOKS table and the category in which each
book belongs. Reverse the sequence of the columns so that the category of each book is
listed first.
9. Create a list of authors that displays the last name followed by the first name for each
author. The last names and first names should be separated by a comma and a blank
space.
10. List all information for each order item. Include an item total, which can be calculated by
multiplying the Quantity and Paideach columns. Use a column alias for the calculated
value to show the heading “Item Total” in the output.