Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with this assignment In this project you will build a database for a public library. This database is aimed to collect and

Please help me with this assignment

In this project you will build a database for a public library. This database is aimed to collect and analyze information about the clients' reading interests. The project concentrates only on books and the clients' interests in books. The analyses that will result from this project will be used by the library's management to decide on the future purchasing policy.

A. Write the SQL statements in order to create the tables for the database. Use the Entity Relationship Diagram (ERD) of the database shown in Figure 1. For simplicity, we are assuming in this project that a book cannot be written by more than one author. You need to create the tables as well as the required constraints, including the keys (primary and foreign), and the relationships between tables.

B. Populate your database with the sample set of data given to you in the tables below the assignment prompts.

C. Write the following queries to retrieve the information detailed below.

Display all contents of the Clients table

First names, last names, ages and occupations of all clients

First and last names of clients that borrowed books in March 2018

First and last names of the top 5 authors clients borrowed in 2017

Least 5 author nationalities clients borrowed during the years 2015-2017

The book that was most borrowed during the years 2015-2017

Top borrowed genres for client born in years 1970-1980

Top 5 occupations that borrowed the most in 2016

Average number of borrowed books by job title

Create a VIEW and display the titles that were borrowed by at least 20% of clients

The top month of borrows in 2017

Average number of borrows by age

The oldest and the youngest clients of the library

First and last names of authors that wrote books in more than one genre

As you work on these queries, create indexes that will increase your queries' performance.

You must include comments in your code that address the purpose of your query and explains each step. Save your queries and results in a plain-text file that you will submit as your assignment.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribedimage text in transcribed

image text in transcribed

Author table: Book table: \begin{tabular}{|l|l|l|l|} \hline BookID & BookTitle & BookAuthor & Genre \\ \hline 1 & Build your database system & 1 & Science \\ \hline 2 & The red wall & 2 & Fiction \\ \hline 3 & The perfect match & 3 & Fiction \\ \hline 4 & Digital Logic & 4 & Science \\ \hline 5 & How to be a great lawyer & 5 & Law \\ \hline 6 & Manage successful negotiations & 6 & Society \\ \hline 7 & Pollution today & 7 & Science \\ \hline 8 & A gray park & 2 & Fiction \\ \hline 9 & How to be rich in one year & 8 & Humor \\ \hline 10 & Their bright fate & 9 & Fiction \\ \hline 11 & Black lines & 10 & Fiction \\ \hline 12 & History of theater & 11 & Literature \\ \hline 13 & Electrical transformers & 12 & Science \\ \hline 14 & Build your big data system & 1 & Science \\ \hline 15 & Right and left & 13 & Children \\ \hline 16 & Programming using Python & 1 & Science \\ \hline 17 & Computer networks & 14 & Science \\ \hline 18 & Performance evaluation & 15 & Science \\ \hline 19 & Daily exercise & 16 & Well being \\ \hline 20 & The silver uniform & 17 & Fiction \\ \hline 21 & Industrial revolution & 18 & History \\ \hline 22 & Green nature & 19 & Well being \\ \hline 23 & Perfect football & 20 & Well being \\ \hline 24 & The chocolate love & 21 & Humor \\ \hline 25 & Director and leader & 22 & Society \\ \hline 26 & Play football every week & 20 & well being \\ \hline 27 & Maya the bee & 13 & Children \\ \hline 28 & Perfect rugby & 20 & Well being \\ \hline & The end & Fiction \\ \hline \end{tabular} Client table: \begin{tabular}{|l|l|l|l|l|} \hline 72 & Annabel & Willamson & 1960 & Cashier \\ \hline 73 & Mohamed & Waters & 1966 & Insurance Agent \\ \hline 74 & Marion & Newman & 1970 & Computer Programmer \\ \hline 75 & Ada & Williams & 1986 & Computer Programmer \\ \hline 76 & Sean & Scott & 1983 & Bus Driver \\ \hline 77 & Farrah & Scott & 1974 & Ship Engineer \\ \hline 78 & Christine & Lambert & 1973 & School Teacher \\ \hline 79 & Alysha & Lambert & 2007 & Student \\ \hline 80 & Maia & Grant & 1984 & School Teacher \\ \hline \end{tabular}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions