Solution
Aditi answered on
Nov 05 2022
From project step 4, you must create and submit a SQL script containing your data manipulation language (DML) statements to insert your sample data into your database and your twenty queries (12 basic, 8 advanced). Within the consolidated technical report, you must include the complete textual output from running your DDL, DML, and queries successfully. You will also include a literature review of similar systems in your report. Your final score will include the evaluation of the collection of output as well as a live, e
or-free expected run of your script in the environment. Within your DML and query scripts, the following minimum requirements must be met:
Data Manipulation Language (DML) SQL Script Minimum Requirements:
1. All Tables Populated with Minimum of 10 RowsÂ
Unless a valid and approved exception exists within your requirements definition document, all tables must have at least 10 rows of sample data.
2. All Su
ogate Keys Populated AutomaticallyÂ
All of your project sequences and triggers must be used to automatically populate your su
ogate keys.
3. Separate DML for Different Tables with CommentsÂ
For readability, each block or grouping of DML statements for each table must be separated with an appropriate comment header with a blank line after the last statement in the group. Note: the last group does not require a blank line afterwards.
4. Executable, E
or-Free ScriptÂ
The script you submit must fully execute and be e
or-free.Â
20 SQL Queries (12 Basic, 8 Advanced) Minimum Requirements:
1. Query 1: Select all columns and all rows from one tableÂ
SELECT * FROM `system li
ary`.patron;
2. Query 2: Select five columns and all rows from one tableÂ
SELECT PatronID, PatronFirstName, PatronLastName, ZipCode, StreetAddress from Patron;
3. Query 3: Select all columns from all rows from one viewÂ
SELECT * FROM vw_books;
4. Query 4: Using a join on 2 tables, select all columns and all rows from the tables without the use of a Cartesian productÂ
Select p.*, b.* FROM patron p cross join bo
ows b;
5. Query 5: Select and order data retrieved from one tableÂ
SELECT * FROM books ORDER BY title ASC;
6. Query 6: Using a join on 3 tables, select 5 columns from the 3 tables. Use syntax that would limit the output to 10 rows
Select bo.ISBN, bo.GenreID, p.PatronFirstName, p.PatronLastName, b.Bo
owID from
Books as bo inner join Bo
ows as b on bo.ISBN = b.ISBN
inner join Patron as p on p.Bo
owID = b.Bo
owID LIMIT 10;
7. Query 7: Select distinct rows using joins on 3 tablesÂ
Select distinct l.Li
arianID, l.Li
arianLastName, s.GenreID, g.Created_By
from Li
arian as l
inner join Sections as s on l.Li
arianID = s.Li
arianID
inner join Genre as g on g.GenreID = s.GenreID
8. Query 8: Use GROUP BY and HAVING in a select statement using one or more tablesÂ
SELECT * from li
arian group by Li
arianID having Li
arianID = 4;
9. Query 9: Use IN clause to select data from one or more tables
SELECT * FROM books where title in ('Apple Cart','Anna Karenina','A Revenue Stamp');
Â
10. Query 10: Select length of one column from one table (use LENGTH function)Â
SELECT title,LENGTH(title) FROM books;
11. Query 11: Delete one record from one table. Use select statements to demonstrate the table contents before and after the DELETE statement. Make sure you use ROLLBACK afterwards so that the data will not be physically removed
Before Delete:
SELECT * FROM `system li
ary`.patron;
After Delete:
Delete from Patron where PatronID =110;
12. Query 12: Update one record from one table. Use select statements to demonstrate the table contents before and after the UPDATE statement. Make sure you use ROLLBACK afterwards so that the data will not be physically removedÂ
Before Updating:
SELECT * FROM `system li
ary`.li
arian;
After Updating:
Update li
arian set Li
arianFirstName = "Kelly" where Li
arianID = 9;
13. Perform 8 Additional Advanced QueriesÂ
i.
SELECT bo.AuthorFirstName
,bo.AuthorLastName
FROM Patron p
JOIN Bo
ows
ON p.Bo
owID = b.Bo
owID
JOIN Books bo
ON bo.ISBN = b.ISBN
GROUP BY bo.Available;
ii. Select distinct l.Li
arianID, l.Li
arianLastName, s.GenreID
from Li
arian as l
inner join Sections as s on l.Li
arianID = s.Li
arianID
iii.
Select p.patronid, p.patronfirstname, p.patronlastname
from patron...