Implement basic sql queries for a given database schema

Assignment Help PL-SQL Programming
Reference no: EM132283876

Aims

Work with an exiting database, by interpreting its schema form SQL.

Implement some basic SQL queries for a given database schema.

Create database views.

Your Task

In this assignment you will be constructing an SQL script that builds a series of database views within the Book Town database. The SQL script containing the Book Town database and its data is available for download

To start your assignment, create a new database and run the booktown.sql script:

[mwelch8@turing mwelch8]$ createdb p1_example

[mwelch8@turing mwelch8]$ psql p1_example psql (9.4.6)
Type "help" for help.

p1_example=> \i /home/cosc210/public_html/assignments/a2/p1_book_town.sql CREATE TABLE
COPY 18 CREATE TABLE COPY 16 CREATE TABLE COPY 15 CREATE TABLE COPY 13 CREATE TABLE COPY 17 CREATE TABLE COPY 16 CREATE TABLE COPY 31
CREATE SEQUENCE CREATE TABLE COPY 36
p1_example=> \dt

List of relations
Schema | Name | Type | Owner
--------+------------+-------+---------
public | authors | table | mwelch8

public | books | table | mwelch8

public | customers | table | mwelch8

public | editions | table | mwelch8

public | publishers | table | mwelch8

public | shipments | table | mwelch8

public | stock | table | mwelch8

public | subjects | table | mwelch8
(8 rows)

This will create a copy of the Book Town database for you to work with.

The views that you construct will return that data speci?ed in the following problem set. Please make sure that you complete your assignment using the template that is provided. Your assignment will be marked with the assistance of automated tools and if the names of the views and their attributes are not correct, you may lose marks.

Question Set

Construct an SQL script (i.e. a ?le with the .sql extension) that contains the de?nitions of the following views.

1. Create a view called 'old_books' that lists the author's ?rst name and last name, book title and edition for every book published before 1990.

2. Create a view called 'programming_or_perl' that Returns a list of the titles of all books with the words 'Programming' or 'Perl' in the title.

3. Create a view called 'retail_price_hike' that returns the ISBN , retail price and a ?nal column that contains the retail price increased by 25%.

4. Create a view called 'book_summary' which returns the ?rst name, last name of each book author along with the books title and subject.

5. Create a view called 'value_summary' that returns the total cost value (cost*stock) and total retail value (retail*stock) across all stock.

6. Create a view called 'pro?ts_by_isbn' that returns the book title, isbn for each book along with the difference between the sum of the cost and retail values across all shipments for each book. The results should be grouped by book title and isbn.

7. Create a view called 'sole_python_author' that returns the ?rst name and last name of any author (If one exists) who publishes all of the books with the text 'Python' in the title (Note the author may publish other books as well but if there are multiple authors of books with 'Python' in the title, no records should be returned).

8. Create a view called 'no_cat_customers' that returns the ?rst name, last name of any customer who has not been shipped any edition of the book named 'The Cat in the Hat'.

Submission

Submit your assignment via turing.une.edu's submit program. The instructions for submit are available here

Make sure that your .sql runs correctly within a database in postgreSQL on turing - You will lose marks if your script does not create all views correctly.

Attachment:- Database Management Systems.rar

Reference no: EM132283876

Questions Cloud

How can we redefine our ideas about success : How will you, as a principal, teach your staff and students that we need to learn from our mistakes to improve our performance?
Parents repeat this game for 52 weeks : On a given week, two selfish parents simultaneously choose between spending time with their children (S) or not (N). The payoff matrix is the following.
How will you have to prepare for the new assessment : How has this video motivated you to look at other assessments that you may not have tried before and as a principal, challenge your staff to do the same?
What is m-l condition : This relation is described by the J-curve. What is M-L condition and how it is related to J-curve?
Implement basic sql queries for a given database schema : COSC210 - Database Management Systems - University of New England Work with an exiting database, by interpreting its schema form SQL - Implement some basic SQL
Does the federal reserve have too much power : Does the Federal Reserve have too much power? Did they overstep their authority in the ways that they have dealt with the problem?
Neoclassical model of investment : In class, we discussed the idea of net investment, and how it could change in response to changes in economic conditions.
Why are mid-ocean ridges : Why are mid-ocean ridges (divergent boundaries) usually offset by numerous transform faults along their length? Feel free to refer to your
How does the analysis impact your perspective of business : Submit a 5- to 6-page synthesis in which you detail the process and results for your small-scale qualitative research project.

Reviews

Write a Review

PL-SQL Programming Questions & Answers

  Create a database model

Create a database model and Submit the table creation statements for the Database Model.

  Write pl-sql procedures and functions

Write PL/SQL procedures and functions to populate and query that database

  Sql questions

Write a query to display using the employees table the EMPLOYEE_ID, FIRST_NAME, LAST_NAME and HIRE_DATE of every employee who was hired after to 1 January, 1995.

  Run the lab_03_01.sql script

Run the lab_03_01.sql script in the attached file to create the SAL_HISTORY table. Display the structure of the SAL_HISTORY table.

  Write sql queries

Write a query to display the last name, department number, and salary of any employee whose department number and salary both match the department number and salary of any employee who earns a commission.

  Explaining sql insert statement to insert new row in cds

Write down a SQL insert statement to insert new row in "CDS" table.

  Write down name of actors in ascending order

Write down actors (or actress, your choice, but not both) who have won at least two (2) Academy Awards for best actor/actress. Provide the actor name, movie title & year. Order the result by actor name."

  What is an sql injection attack

What is an SQL injection attack? Explain how it works, and what precautions must be taken to prevent SQL injection attacks.What are two advantages of encrypting data stored in the database?

  Determine resonant frequency in series rlc resonant circuit

Given the series RLC resonant circuit in the figure, operating at variable frequency, determine: The resonant frequency ω o ,  The circuit’s quality factor Q , The cut-off frequencies, f 1  & f 2  and the bandwidth BW

  Query that uses cube operator to return lineitemsum

Write summary query which uses CUBE operator to return LineItemSum (which is the sum of InvoiceLineItemAmount) group by Account(an alias for AccountDesciption).

  Query to show customers were missing for existing orders

As DBA, your manager called a meeting and asked why there are so many orders for customers that don't exist in the customer table. Write query which would shows which customers were missing for existing orders. Use a join or a subquery.

  Sql query into a relational algebra statement

Turn this SQL query into a relational algebra statement? SELECT Request.reqfor, Ordering.invamt, Ordering.invnbr, Ordering.invdat

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd