Create tables using sql ddl

Assignment Help PL-SQL Programming
Reference no: EM13318466

Part A: SQL Queries

Use the prime_minister database (prime_minister.sql) from the Interact Resources site. Answer the following queries from that database.

You are required to submit:

  1. The appropriate SQL statements for each query, which should be copied from your SQL code in MySQL and pasted into your submission file;
  2. Your SQL script, which is either for each question--one-step solution, or for the two sub-questions of each question-- two-step solution; and
  3. Screenshots of the resultant tables which are to be pasted into your submission file immediately after the SQL code for that query. Typing or manually drawing the results is NOT acceptable.

NOTE:

1. Your SQL code should be correct for any data, not just any sample data that you create.

2. If your query results are contradict with the fact, please still present your answers based on the given prime_minister database.

3. The final query results by either one-step solution or two-step solution for each question should be the same.

Write SQL SELECT statements to retrieve the following information from the prime_minister database: Answer all questions

1. Find all Governors General of Australia who were Barons at the time of their appointment. List them by Title and name and date that they were appointed to the position. Order the list by ascending date of appointment.

You can choose to answer this question in two steps:

a.Restrict your query to Governors General who were Barons at the time of their appointment

b.Then format the date of appointment as day of the week, day of the month, month and year; eg. Monday, 01 January, 1901. Order the list by ascending date of appointment.

2. Find all the Leaders of the Opposition and their date of appointment who gained their position after 01/01/1980, their wife's name and their date of marriage. Order the list by ascending date of appointment.

You can choose to answer this question in two steps:

a. list those who were the Leaders of the Opposition and their date of appointment who gained their position after 01/01/1980.

b. For each Leader of the Opposition listed as above, add their wife's name and their date of marriage.

3.Who are the Leaders of the Opposition who were not members of a Labor party and who gained their position after 01/01/1980. List their name, date of election in the format month, day of week and year, eg: January 1st, 1980, spouse's name and their year of marriage. Order the list by ascending date of appointment.

You can choose to answer this question in two steps:

a. List whose who are the Leaders of the Opposition who were not members of a Labor party. Order the list by ascending date of appointment

b. Based on the result of Q.3a, list whose who gained their position after 01/01/1980. Order the list by ascending date of appointment

4.List the title, name, date of appointment for Governors General of Australia who were appointed between 01 January 1930 and 01 January 1960, together with the Prime Ministers who appointed them and all Leaders of the Opposition who served during their appointment. The date is to be formatted in dd/mm/yyyy format. Order by ascending date of appointment.

You can choose to answer this question in two steps:

a. List the title, name, date of appointment for Governors General of Australia who were appointed between 01 January 1930 and 01 January 1960. Order by ascending date of appointment.

b. Together with the result of Q.4a, list the Prime Ministers who appointed them and all Leaders of the Opposition who served during their appointment. Order by ascending date of appointment.

5. Who are the Opposition Leaders who subsequently became Prime Minister after 1930 ? List their name, the date they were elected Opposition Leader and the date they were elected Prime Minister and their Deputy Prime Minister's name and the party that they led. The dates must be formatted as day of the week, day of the month, month in digits and year in four digits; eg. Monday, 01/01/1901. Order the list by ascending date of appointment as Opposition Leader.

6.. Who are the Prime Ministers who led a non-ALP party before 1930? List the Prime Ministers name, the year they commenced as Prime Minister, their party, their Deputy Prime Minister, the number of times that they were elected as Prime Minister and the title and name of the Governor General at the time they commenced office.     

Part B. Create Tables using SQL DDL

The following questions are based on the Bicycle Rental ERD as shown below:

1443_Create Tables using SQL DDL.png

Tasks:

  1. Write the SQL DDL to create the database that contains each of the relations shown in the above ERD. You will need to provide:
    1. Your DDL code for each table that you create;
    2. A screenshot showing each table that is created.
  2. Write and execute SQL definition commands for each of the following queries:
    1. Add the attributes Email, Comments and Send Newsletter to the Renters table. Give those attributes an appropriate size and data type.
    2. Change the attribute Renters.renterDOB from type Varchar(15) to type DATE.
  3. Write and execute SQL commands for the following:
    1. Add the following customers to the Renters table.
    2. Write a command that will remove the Jones that lives in Orange from the Renters table

id_r

r_lname

rent_fname

r_address

r_town

r_state

r_pcode

r_phone

r_dob

12345

Jones

George

123 Bentinck St

Bathurst

NSW

2795

0212345678

01/05/1964

23456

Jones

Pauline

48 Summer St

Orange

NSW

2800

0223456789

11/09/1986

28765

Wilson

Paul

23 Long St

Blayney

NSW

2799

0298745621

22/12/1977

You are required to submit:

  1. The appropriate SQL command which should be copied from your source code in MySQL and pasted into your submission file; and
  2. The resultant tables, which must be screenshots to show the change due to the execution of the SQL commands.

Reference no: EM13318466

Questions Cloud

Determine the final speeds of the particles : A particle of mass 7.22 x 10^-27 kg, moving at 7.06 x 10^5 m/s, strike an identical particle which is initially at rest. What are the final speeds of the particles
Determine the speed of the pribe realitive to earth : A spaceship moves away from Earth at a speed 0.417 c and fires a shuttle craft that then moves in a forward direction at 0.701 c relative to the ship. determine the speed of the pribe realitive to earth
Details co held bonds of schooner corp with a cost : Details co held bonds of schooner corp with a cost
Obtain the magnitude of the force : Two particles, one with charge -7.13 %u03BCC and one with charge 7.75 %u03BCC, are 3.59 centimeters apart. What is the magnitude of the force that one particle exerts on the other
Create tables using sql ddl : Write the SQL DDL to create the database that contains each of the relations shown in the above ERD. You will need to provide - Your DDL code for each table that you create and a screenshot showing each table that is created.
Describe and discuss the standards and rulings : Go to a website that discusses FASB, SEC, IFRS, and/or IASB. Describe and discuss the standards and rulings that are being contemplated through pending discussion drafts and exposure documents of FASB and IASB.
How much magnetic energy does it contain : A 500-turn solenoid is 23 cm long, 1.5 cm in diameter, and carries 65 mA. How much magnetic energy does it contain
What is the ratio of new line power loss to old : A large power plant generates electricity at 12.0 kV. Its old transformer once converted the voltage to 395 kV. If the upgraded transmission lines have the same resistance, what is the ratio of new line power loss to old
What are the best dimensions for a trapezoidal canal having : What are the best dimensions for a trapezoidal canal having a side slopes of 1V : 3H and n = 0.020, if it is to carry 40 m^3/s uniformly on a slope of 0.009.

Reviews

Write a Review

PL-SQL Programming Questions & Answers

  Script that creates and calls a function named

Write a script that creates and calls a function named fnDiscountPrice that calculates the discount price of an item in the OrderItems table (discount amount subtracted from item price). To do that, this function should accept one parameter for th..

  Write queries in sql and relational algebra

Write given queries in SQL and relational algebra: Determine cities from which one can fly to Toronto with one change of planes, and using same type of the aircraft for both legs of trip.

  Update stock levels when the order is cancelled

Execute queries to confirm that the basket order status and product stock levels have been appropriately modified by the trigger - the trigger needs to fire when a new status record is added to the BB_BASKETSTATUS table and when the IDSTAGE col..

  Write a xquery which returns all concert titles

Write a XQuery which returns all concert titles whose type is chamber orchestra where average ticket price is at least $50.

  Review problem and run required statement to create table

Please note that for "Table Employees" due to length of the table description and page size limit, I have broken it into 2 parts for better visibility, please make sure to use all the given attributes from the table.

  Explaining sql insert statement to insert new row in cds

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

  Can we offer an example of a query

Can we offer an example of a Query in which we can use a parentheses to affect the order of execution in which the WHERE Clause has both AND and OR Logical Operators?

  Describe the meaning of keyword exists and not exists

Describe the meaning of the keyword EXISTS. Describe how any and all relate to EXISTS and NOT EXISTS. Write a query which will display names of any customers who are interested in all artists.

  Write a pl-sql block

Write a PL/SQ block - Select the average salary of all employees in department number 20.

  Write down sql needed to create employee table

Write down SQL needed to create employee table containing the following data: employeeID, text, length of 5, primary key lastName, text, length of 25

  Decomposition for r = (a,b,c,d,e )

Give a good decomposition for R = (A,B,C,D,E ) with the following functional dependencies:

  Find the sum of the elements of a

A is an ArrayList of size N. The elements of A are integers, they are in sorted order increasing from the low end of the array, and no two integers are the same. Variable x is an integer. Which of the following operations takes time that is less t..

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