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

  Adjustment case study go to npr storycorps website

Assignment: Adjustment Case Study Go to NPR's StoryCorps Website, located at http:/www.npr.org/series/4516989/storycorps. Read two (2) articles that were published within the last two (2) months that focus on individuals with major adjustment issu..

  Updating column in table after a shopper completes the

after a shopper completes the ordering process a procedure is called to update the following columns in the basket

  Identify and track relationships between individuals

Which one yielded better results? What metrics did you use to evaluate which results were better - How do the results differ across different types

  List the movies which have more than one director

List the movies which have more than one director. Include the year, title, last and first name of directors. Sort the output by last name within title. (use subquery)

  Write pl-sql procedures and functions

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

  Testing dependencies on stand-alone program units

In this chapter, you learned about direct, indirect, and remote dependencies. Define these dependency types, and explain how they differ in program unit invalidation and recompilation - you verify the effect of object modifications on the status of..

  Write a perl subroutine for temperature conversion

Write a perl subroutine for temperature conversion named ' convert_temp '. It should be able to handle both Fahrenheit to Celsius conversions as well as Celsius to Fahrenheit conversions.

  Write the t-sql statement that would create a table

Write the T-SQL statement that would create a table named "Team". The table should contain 3 attributes -TeamID, TeamName and Established

  Design one table that is in first normal form

Design one table that is in first normal form and fulfills the following requirements: The table should have a primary key that uniquely identifies the records. The values in each of the columns should be atomic.

  Show me the code whereby after user has inserted

I need someone to create a form using notepad ++ and show me the code whereby after user has inserted his/her details from the form you can get the details from the database.

  Draw an entity relationship model for galle face elephants

Using the Oracle Developer Data Modeler tool, draw an Entity Relationship Model for the Galle Face Elephants case study above. Explain any assumptions you have made.

  Find the old department name from the departmenttable

Find the old department name from the departmenttable based on the old department_id. Create a trigger called fin_job_min_sal_trg on the employee table. When an INSERT or UPDATE statement is issued against the employee table.

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