Database Concepts, assignment 1 Page 1 of 4
BIS 234, Semester 1, 2018 Database Concepts Assignment 1 Part B and Part C Prepared By: Dr Jamal El-den, Craig Coley Due date: Friday, Week 7 Value: Part B 4% tables and advanced queries
Part C 10% covers all topics Submission details:
• You already have Part 1 of this assignment. Part B and C are below
• Please submit all 3 parts of the assignments together.
• For Internal and External students: submission is via Learnline. Instructions on how to
submit the assignment is located under Assessments / Guidelines.
Part B: Table and Advanced Queries
Please answer all four questions.
For Question 1 provide the following:
• The SQL statement (4 of the marks)
For Question 2 provide the following:
• The SQL statement (3 of the marks)
For each Question 3 and 4 you have to provide the following:
• The SQL statement (3 of the marks)
Database Concepts, assignment 1 Page 2 of 4
1. The following Gym application database for weight session recording is as follows
Write and run SQL statements for the Occurrence_exercise table.
OCCURENCE
OccurenceID Occ_ Date Occ_Place Occ_Start_Time Occ_Finish_Time
OCCURRENCE_EXERCISE
OccExID ExerciseNo OccurenceID REP Attempt1 Attempt2 Attempt3 Condition
EXERCISE
ExerciseNo ExerciseDecription ExerciseType
Include constraints values for the Condition: Heavy, Medium, Light
2. Write an SQL statement that will insert the data into Occurrence_Exercise table only.
OCCURENCE
OccurrenceID Occ_ Date Occ_Place Occ_Start_Time Occ_Finish_Time
0001 14 MAR 18 University Gym 16:00 16:30
0002 15 MAR 18 University Gym 16:30 17:00
0003 16 MAR 18 University Gym 16:10 17:20
0004 17 MAR 18 Home 7:00 8:00
0005 17 MAR 18 University Gym 17:00 18:00
OCCURRENCE_EXERCISE
OccExID ExerciseNo OccurrenceID REPS Attempt1 (kg)
Attempt2 (kg)
Attempt3 (kg)
Condition
9001 001A 001 8 15 15 15 Light
9002 002A 001 8 70 75 70 Medium
9003 003A 002 12 90 95 90 Heavy 9004 004A 003 12 200 200 200 Medium
9005 006A 003 8 110 110 115 Heavy
9006 005A 004 10 20 25 Medium
9007 001A 004 8 10 12 10 Medium
9008 002A 005 8 85 90 115 Heavy
Database Concepts, assignment 1 Page 3 of 4
EXERCISE
ExerciseNo ExerciseDecription ExerciseType
001A Situps Abs
002A Bench Press Chest
003A Dead Lifts Back
004A Leg Press Legs
005A Seated Shoulder Press Shoulders
006A Squats Legs
007A Lat pull downs Lats
Definition of rep stands for repetition.
Each exercise attempt has the rep number as indicated in the occurrence table.
Create the following queries
3. Find the exercise which contains the maximum total weight lifted Show: Exercise, Maximum weight Ensure you show captions for each of the columns Hint: you would need to consider the number of times the weight is lifted and weight e.g. rep multiplied by attempt
4. Find the exercise that the user was not able to complete 3 attempts in, or the exercise that the user has not attempted.
• Show appropriate columns • List in ascending order exercise type. • Do not show repeated names
Ensure you show captions for each of the columns
Database Concepts, assignment 1 Page 4 of 4
Part C: For the first four questions refer to the Library Database For question 5 refer to CDU Customer invoice Database Please answer all five questions.
For each question you have to provide the following:
• The SQL statement (3 of the marks) except for question 4 (4 of the marks)
Using Library Database
1. What are the 5 most popular books?
• Show ASBN, Title
HINT: To limit results use ROWNUM.
2. Which branches currently have no loans out?
• Show all branch names • List in ascending order by branch.
3. Find the longest time a book has been loaned out for each branch
• Show only branch name and number of days • List in ascending order by branch name • Show all branches • A branch may have a null value • Format the number of days to one decimal place
4. Find the borrower that has returned a book on the dated 16 December 2010 and 8 May 2012
Show two different methods
5. Devise a delete query, which will eliminate duplicates for columns customer id, customer last name, customer first name, Invoice date, Invoice No.
Ensure the query removes all duplicate data.