Create your own question based on the library database


Assignment: Database Concept

Part A - Single and multiple table queries

For the first five questions you have to provide your answer in the form of a SQL statement, with description before as necessary. For example:

1. Example Question: Select all columns from the `Customer` table Example Answer:

-- This answer will select out all the columns from the Customer table SELECT * from Customer;

Questions 1 - 5:

1. List in ascending order the Last Names of all borrowers with Card Number less than 150.

2. What are the records of those loans between 3 June 2014 and 8 Mar 2018?

o The output should include the name of the cardholder, and title of the book
o List in ascending order by last name and first name

3. Find the total numbers of loans with last name beginning with D through E (including E); include last name beginning with Q as well as Z also.

4. Find all borrowers for a loan that have the Date-in before 15-March-15 and the Card number between 100 and 300 in Karama or Darwin.

5. Find the number of loans, which have been made from each branch?

o Note all branches need to be included even those with no loans

Question 6:

6. Create your own question based on the library database, and also provide a SQL Statement to answer your question.

Part B - Table and Advanced Queries

The questions are broken into: Q1, Q2, Q3 and Q4. For all questions, provide the answer in the form of a SQL statement, with description before as necessary.

Questions

NOTES

Questions 1 and 2 require you to answer in the form of a SQL statement to create a table and insert data into it. The question and answer is only about the statements to create and put data into the

`Occurrence_Exercise` table, however it is recommended that you create the statements to create and insert data into all 3 tables, so that you can test that your statements are correct. Please only provide in your answer the SQL statement for the `Occurrence_Exercise` table.

To understand the terminology:

• A rep is a number of times you do an attempted weight.
• A set is an attempt and in this case, there are 3 attempts (attempt 1, attempt 2, attempt 3).
• An attempt contains the weight.

So to understand the weight you would lift for a single exercise in the Exercise attempt table you would need to consider the rep multiplied by attempts by the weight. So for a single attempt:

e.g. for 9001
rep multiplied by attempts by the weight
8 reps x 3 attempts x 15kg = 360 total kg's lifted

1. The following Gym application database for weight session recording is as follows. Write and run SQL statements for creating the Occurrence_Exercise table.

o Include constraint values for the Condition Column: Heavy, Medium, Light

2. Write an SQL statement that will insert the data into Occurrence_Exercise table only.

o Definition of rep stands for repetition.
o 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

o Show: Exercise, Maximum weight
o Ensure you show captions for each of the columns
o Hint: you would need to consider the number of times the weight is lifted and weight
e.g. rep multiplied by attempt multiplied by the weight

4. Find the exercise that the user was not able to complete 3 attempts in, or the exercise that the user has not attempted.

o Show appropriate columns
o List in ascending order exercise type
o Do not show repeated names
o Ensure you show captions for each of the columns

Part C - All Topics

For the first four questions refer to the Library Database. For question 5 refer to CDU Customer Invoice Database.

The questions are broken into: Q1-4 and Q5.

For all questions, provide the answer in the form of a SQL statement, with description before as necessary.

Questions Using the Library Database

1. What are the 5 most popular books?

o Show ASBN, Title.
o HINT: To limit results use ROWNUM.

2. Which branches currently have no loans out?

o Show all branch names.
o List in ascending order by branch.

3. Find the longest time a book has been loaned out for each branch

o Show only branch name and number of days.
o List in ascending order by branch name.
o Show all branches, even if there are no loaned out books. Therefore, a branch may have a null value for the longest loaded out book.
o 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

o Show two different methods.

Question Using the CDU Customer Invoice Database

5. Devise a delete query, which will eliminate duplicates for customer columns `ID`,

`CustomerLastName`, `CustomerFirstName` and invoice columns `Invoice_Date` and
`Invoice_No`.

o Ensure the query removes all duplicate data.

Format your assignment according to the following formatting requirements:

1. The answer should be typed, double spaced, using Times New Roman font (size 12), with one-inch margins on all sides.

2. The response also includes a cover page containing the title of the assignment, the student's name, the course title, and the date. The cover page is not included in the required page length.

3. Also include a reference page. The Citations and references should follow APA format. The reference page is not included in the required page length.

Attachment:- Assignment-Database-Concept.rar

Solution Preview :

Prepared by a verified Expert
Database Management System: Create your own question based on the library database
Reference No:- TGS02983991

Now Priced at $45 (50% Discount)

Recommended (99%)

Rated (4.3/5)