Module 3 Case Study 1
Module 3 Case Study 1
COMP2714 Module
Module 3 Case
3 Case Study
Study 1 1
Focus
The purpose of this case study is to help students develop practical experience in implementing a
database system. You will learn how to identify and solve issues which commonly occur during
database setup. Additionally, you will become familiar with SQL Data Definition Language (DDL) and
its practical usage in a commercial environment.
Task
correspondence on the pages below, complete
Using the correspondence complete the
the following
following tasks.
tasks. Please ask your tutors
for help if you require clarification on any aspects of the brief.
Note: Stating clear data corruption such as in the SQL for the “TimeLog” table will not be
accepted.
Example Error
Error `hobby` varchar(1) NOT NULL,
Implications An attribute of varchar with length 1 can only store a single letter.
Implications
Correction
SQL Error 2
Error
Implications
Correction
SQL Error 3
Error
Implications
Correction
Based on the CSV files provided in Peter’s first email, the INFS1200 tutors have identified three
data entries which are either incorrect or cause runtime errors during the initial import. For each
entry, you are required to write an SQL statement to remedy the error and also identify when the
statement must be run. For each error you will be provided an SQL keyword which you must
correctly use in your answer. An example has been provided below with the solution in red.
Note: You must use the SQL keyword provided for each given problem. Additionally, your SQL
query must not cause any additional errors to occur when the CSV import is run.
Example Error
Error 3039,Jennifer,Robinson,Developer
Explanation This employee should have the role “Administration” not “Developer”
SQL Solution UPDATE Employee SET role = "Administration" WHERE id = 3039
When to Run Before Employee CSV Import / After Employee CSV Import
(Highlight Correct)
When to Run Before Employee CSV Import / After Employee CSV Import
(Highlight Correct)
CSV Error 2
Error 2020 Marketing,Develop a marketing plan for 2020,43126.78,3009
When to Run Before Project CSV Import / After Project CSV Import
(Highlight Correct)
CSV Error 3
Error Office Redesign,Redesign office to increase
productivity,2000.50,3010
Explanation Tuple violates referential integrity constraint as the Builder “Aaron
Smith” with id 3010 is missing from the Employee table.
SQL Solution INSERT
When to Run Before Project CSV Import / After Project CSV Import
(Highlight Correct)
According to Peter’s email dated the 2nd of May, data corruption during a database export resulted
in the SQL import queries for the TimeLog and ProjectExpenditureTimeline tables not being
generated. Using the information provided in that email and its attachments, write the SQL queries
to:
1) Generate the missing tables (without foreign keys)
2) Apply any needed foreign keys or missing constraints
Note: You must choose suitable data types when generating tables.
YOUR SQL QUERIES TO APPLY ANY NEEDED FOREIGN KEYS OR MISSING CONSTRAINTS
MUST FIT IN HERE
In Peter’s email to Elaine dated the 5 th of May, he presented several schema modifications for Dirt
Road Driving payroll backend. For each schema modification, write SQL query(s) to apply the
modification.
Schema Query 1
Client Employee’s middle names (if they have one) will also be stored along with their first name and
Specification last name.
SQL
Query(s)
Schema Query 2
Client The employee’s ‘role’ will be stored as a text datatype to allow for longer descriptions.
Specification
SQL
Query(s)
Schema Query 3
Client The combination of first name and last name for each employee must be unique.
Specification
SQL
Query(s)
Schema Query 4 - A
Client To increase productivity, each employee will be assigned to a “main project,” which
Specification they are expected to spend the majority of their time on:
- Add an attribute called “mainProject” to the employee’s table which can store
the main project name. Each employee already in the system should be
assigned “Website Setup” as their main project.
SQL
Query(s)
In addition to schema modifications, Peter’s second email dated 5 th of May also requested for the
database’s data to be updated to reflect several developments within the company. For each of these
requests, write SQL query(s) to make the needed changes in the needed tables. Note: at no point
should your queries result in incorrect data being stored in the database, even if only temporarily.
Data Query 1
Client On the 3/5/2020 Annie Fang worked for 4 hours on the “Website Setup” project and
Specification this time has been approved.
SQL
Query(s)
Data Query 2
Client Gabriele Cirulli was fired.
Specification
SQL
Query(s)
Data Query 4
Client The Board of Directors approved a new $8000.00 project called “New Zealand
Specification expansion analysis” which is designed to look into the economic and logistical
feasibility of setting up a branch of Dirt Road Driving in New Zealand. To lead this
project, we have hired a new manager, “Charlie Johnson” and assigned him ID 2930.
Charlie will also be assigned this project as his “main project.”
SQL
Query(s)
Hi Elaine,
I hope you are having a nice weekend! Please thank your student teams for their responses
regarding the source of our problematic payroll system commands, it was really appreciated!
After consulting with our IT department, they have informed me that they would like to redeploy the
current payroll database to a MySQL system. They feel this will prove more stable in the long run
and provide greater opportunities for future expansion. Initially, we just wanted to just roll out a small
portion of the database similar to what I sent in my last email. However, when our database
administrator did an SQL export of the old database system, it appears the import file and data which
was generated was possibly corrupted casing the import to fail. Due to the high use of the system,
we cannot schedule any downtime within the next month to rerun the export. As such, we were
wondering if your student team would be able to take a look at these files then identify any errors
and write/rewrite the appropriate SQL statements to fix these errors?
Please let me know if your student teams require any further information. Also, please pass on our
sincere appreciations to them for their help!
Kind regards,
Peter Thompson
Director of Innovation | Dirt Road Driving
1) Employee.csv
Click here to open the Employee.csv attachment.
2) Project.csv
Click here to open the Project.csv attachment.
3) TimeLog.csv
Click here to open the TimeLog.csv attachment.
Hi Elaine,
Thank you for your call yesterday to confirm the INFS1200 student teams would be able to assist in
solving these issues with importing our payroll system.
In addition to the fixing the corrupted queries and data I sent in my last email, I was also wondering
if your student teams would also be able to assist in writing queries to make some minor adjustments
to the payroll backend? I have divided these adjustments into two categories, schema queries and
data queries. For each situation highlighted by these dot points, could your students please provide
the necessary SQL queries to apply any needed changes in the backend?
Schema Queries:
1) Employee’s middle names (if they have one) will also be stored along with their first name
and last name.
2) The employee’s ‘role’ will be stored as a text datatype to allow for longer descriptions.
3) The combination of first name and last name for each employee must be unique.
4) To increase productivity, each employee will be assigned to a “main project,” which they are
expected to spend the majority of their time on. In order to implement this, we need two tasks
completed:
A. Add an attribute called “mainProject” to the employee’s table which can store the main
project name. Each employee already in the system should be assigned “Website
Setup” as their main project.
B. This new attribute needs to be a foreign key referencing the Project.name attribute.
Because each employee must have a valid main project, this attribute should also not
be null.
Data Queries:
1) On the 3/5/2020, Annie Fang worked for 4 hours on the “Website Setup” project and this time
has been approved.
2) Gabriele Cirulli was fired.
3) Due to the corrupt export, the ProjectExpenditureTimeline table needs to be populated.
(Note: Because we only provided you with a snapshot of our data, we need a query which
populates this table based off the TimeLog table and not just specific insert queries.)
4) The Board of Directors approved a new $8000.00 project called “New Zealand expansion
analysis” which is designed to look into the economic and logistical feasibility of setting up a
branch of Dirt Road Driving in New Zealand. To lead this project, we have hired a new
manager, “Charlie Johnson”, and assigned him ID 2930. Charlie will also be assigned this
project as his “main project.”
Sorry for these additional requests, we have been exceptional busy these last few days. Again, we’d
like to thank you and your team for your ongoing support!
Kind regards,
Peter Thompson
Director of Innovation | Dirt Road Driving