Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

COIT20247 Database Design and Development (T1 2023)

Assignment 2

Due date 11:45pm on Friday of Week 10 (May 19, 2023)

Weighting 35%

Length Not applicable

Objectives
This assessment item relates to the unit learning outcomes numbers 1, 2 and 3 as stated in the unit
profile.

Introduction
The sample solution of assignment 1 will be released on the unit website approximately two (2)
weeks after the assignment 1 due date. You must use that sample solution of assignment 1 only for
the following tasks:

Assessment task
1 ER Mapping and Normalization

a) Map the ER diagram, from the sample solution, into a set of relations in at least Third
Normal Form (3NF). You must ensure that your relations meet 3NF. There is no need to
show your working. You must specify the primary key, and foreign key (if any) for each
relation.
b) Select any two of your relations from the previous step (1a), and perform the following for
each of those two relations:
• List all the functional dependencies exist in the relation.
• Demonstrate that the relation meets Third Normal Form (3NF).
For your help, an example for a student relation’s 3NF justification has been provided below:

STUDENT (StudentID, Name, Address, DateOfBirth)

i. The primary key is StudentID which identifies a student. There will be one student name
per Student ID because only one name is recorded for each student. Even though a
student may have multiple addresses (e.g., a home address and a work address), the
case study states that there is a need to record the home address only and hence there
will be only one address for each student. There will be only one date of birth for each
student. Thus, there are no repeating groups. Hence, this relation is in 1NF.
ii. The primary key is StudentID. This is the only candidate key since Name is not
guaranteed to be unique (two different students may have the same name). Address is
also not guaranteed to be unique. This means that Student ID functionally determines
every other attribute in the table. There is a single valued simple candidate key
(StudentId) and therefore no partial dependencies are possible. Hence, the relation is in
2NF.
iii. Name cannot be used to functionally determine any other attribute in the table since
two different students may have the same name: likewise for address and date of birth.
Therefore, there are no transitive dependencies in the table. Therefore, it meets the
requirements of first, second and third normal form.

2 Use MySQL Workbench to create the logical database model


Consider the E-R model on the motel booking as the solution of assignment 1 released, Use MySQL
Workbench 8.0 CE to create a logical database model with the relations as in Part 1(E-R mapping and
normalization), include specifying the primary keys, foreign keys, creating relationships as
appropriate, and creating the ER diagram. Save the file as cqac.mwb

3 Relational database implementation using MySQL Server


Use MySQL Server to perform the physical implementation of the designed database from the above
logical model and export the database file as cqac.sql. In implementing the ER model provided, you
must complete the following tasks:

• Create all the relations in a MySQL database. Consider each attribute in every table and
make appropriate choices regarding data types & sizes, null allowed or not. Your choices
should be appropriate for each attribute and should support data integrity.
• Indexing can speed up search for tables or queries. Review the guideline given in the
textbook regarding set-up of index. You should at least ensure the last name and phone
attributes in the Guest table to be indexed, and the motel name attribute in the Motel table
to be indexed.
• Populate the database with sample data of your own. You must include sufficient sample
data to test your queries and report. Please note that the expected result of query questions
as below should depend on the actual sample data populated.
You also can implement your database using MySQL Workbench or via Command Line Client. (Note:
Week 6 lecture and tutorial provide the instructions how to export a MySQL database file)

Data integrity
You are required to implement a constraint of data integrity to enforce the requirement that the
booking end date is later than the booking start date. You can save this constraint as the file
MyIntegrityConstraint.sql

Stored procedures
In databases, a stored procedure is a piece of prepared SQL code that you can save, execute and
reuse at any time. You are required to write a stored procedure.

Information requests
Create queries to answer the following information requests. You should type the query codes
manually using SQL view/editor under MySQL Server.

The marking process of the queries for information requests may also consider the effectiveness of
your SQL statements that have been used in the queries. It is important that your SQL statement
must reflect the correct business logic & SQL syntax. (Use enough sample data so that the output is
produced by each query. The expected result is under each question. Under MySQL Server, save
each query question SQL statement as a file such as q1.sql, …, q5.sql.

1. Who are the residents in respite care? List the residents in respite care that include their
name, date of birth, emergency contact, the contract start date, contract end date
details.
2. How many rooms have been managed by each care manager? Show the manager’s
name, the number of rooms managed by them. Order the list so that the manager who
has managed the most properties appear first.
3. List the details of repair jobs performed by handymen for the facility in the last 3
months. The details should include the job ID, job description, the completed date,
charge, roomID and the handyman’s name.
4. Which rooms have received more than one application in the last 12 months? Show the
room ID, room type, daily rental and the number of applications.
5. Find the details of the staff who has the highest annual salary. The details should their
id, name, address, include the type of staff – nurse, personal carer or care manager.
6. Show the details of residents who have lived in the care for more than 3 years grouped
by the type of care they receive. This detail is important as the government want to
calculate the number of elderly people who may be paying the means tested fee which
ceases after staying 3 years or more in care. So, the details in the output should include
the resident’s name, contact phone, the roomType, type of care a resident is currently
receiving and the cost of the room.
Implementation Report
You must also provide a short implementation report describing your experiences with this
assignment. You may discuss any of the following:

1. Any two interesting things/procedures you learnt by doing this assignment.


2. Any one requirement of the assignment that was relatively difficult / complex to solve but
successfully completed by you.

Use the implementation report to demonstrate that you have thought carefully about the issues that
arise when implementing a relational database.

What you should submit


Place the following files in a zip file named Ass2.zip and submit via moodle assignment 2 link

1. MySQL Workbench logical database model file – cqac.mwb


2. MySQL database file – cqac.sql containing:
• Create table SQL statements
• Tables with sample data with insert SQL statements
• Create indexes
• The required stored procedures
3. The files of answering five information request questions (q1.sql,…., q6.sql)
4. Data integrity implementation file - MyIntegrityConstraint.sql
5. A Microsoft Word document containing:
• A set of relations mapped from E-R diagram (3NF)
• Two relations with functional dependencies and demonstration of normalization
• Implementation report

Your document should contain appropriate identification information (your student number, name,
unit number, etc.) and should contain the relevant headings for each section.

Important points
• You must work individually on this assignment.
• The model solution to this assignment will be released approximately two (2) weeks after
the due date.
• Assignments that are submitted after the release of the model solution will receive zero
marks.
• You must state in your word document the details of all materials and sources that you used
to complete this assignment. This may be as simple as 'This assignment was completed using
only the COIT20247 unit materials'.
• Extension requests (by filling in an online form) should be submitted before the assignment
due date.
• Before submitting your assignment, review the marking criteria provided on the last page of
this document. Ensure that all the criteria are addressed in your submission.
• Penalties related to late submission and plagiarism will be applied as per university policy.

You might also like