Question

In: Computer Science

NOTE: If the default database date format for the Oracle Server you are using does not...

NOTE: If the default database date format for the Oracle Server you are using does not show a four digit date you can issue a command to change the default to something you prefer. Examples:

alter session set nls_date_format ='DD-MON-YYYY';

alter session set nls_date_format ='Month DD, YYYY';

  1. Create a logical view of your presidents table named ModernPresidents that shows all of the presidents since the end of World War II. Harry Truman was the president at that time so you can start with him.   In your view please show these columns:

PRESNUM

NAME

TOOKOFFICE

LEFTOFFICE

DAYSINOFFICE (the number of days they were in office)

Specify that the order of the table should be PRESNUM ascending

Hint: If you subtract one date from another what is returned is the number of days between those two dates.

  1. Create a view name PresidentStates that has two columns: The name of every state in the presidents table and the number of presidents that have been from that state. Name that column NUMPRESIDENTS and have the rows in your view in order from the state with the most presidents to the state with the fewest presidents. So that the number of presidents in each state doesn’t have to be computed over and over again every time someone uses this view make it a materialized view. Since updates to this table will not be very frequent make any update of the materialized view a full update and have it happen whenever a change to the presidents table is committed.    You can test if your MV works by change a presidents home state, looking at your view, and then change the state back again.

Solutions

Expert Solution

Solution:

Part 1 View :

it has been assumed that PRESIDENT Table has got all the required columns to be used in the view. The WHERE clause specifies the condition to pick up only the PRESIDENTS which had TOOKOFFICE date > WWII end date. (Kindly replace the MM-DD in green below, with the date to be used for the WW-II end date). The expression LEFTOFFICE - TOOKOFFICE will yield the days in office.

CREATE VIEW ModernPresidents

(PRESNUM, NAME, TOOKOFFICE, LEFTOFFICE,DAYSINOFFICE)

AS SELECT PRESNUM, NAME, TOOKOFFICE, LEFTOFFICE,LEFTOFFICE - TOOKOFFICE

FROM PRESIDENT

WHERE TOOKOFFICE > DATE '1945-MM-DD'

Part 2 : Materialized View

It has been assumed that PRESIDENT table has got the "State" column which stores the name of the state.

Brief Description: The REFRESH COMPLETE will take care of the full update requirement. ON COMMIT clause will fulfill the requirement for the refresh to happen when table PRESIDENT is committed. ORDER BY will sort the values in descending order of the "number of presidents" .

create materialized view PresidentStates

REFRESH COMPLETE ON COMMIT

as

select count(PRESNUM) as NUMPRESIDENTS, state

from President

Group by state

order by count(PRESNUM) DESC

;


Related Solutions

You need to design a Web Server, Database Server and a Backup server. If you had...
You need to design a Web Server, Database Server and a Backup server. If you had to choose from the following list of resources which ones would you place a priority on and state why you would do so. List these for each server type. Hint: You need to think about the functionality of the server. Based on this information, which resource would you emphasize on the most to increase the performance of the server. CPU utilization and speed Multiprocessing...
On what date does this note mature?
Question: Keesha Co. borrows $200,000 cash on November 1, 2017, by signing a 90-day, 9% note with a face value of $200,000. 1. On what date does this note mature? 2. How much interest expense results from this note in 2017? (Assume a 360-day year.) 3. How much interest expense results from this note in 2018? (Assume a 360-day year.) 4. Prepare journal entries to record (a) issuance of the note, (b) accrual of interest at the end of 2017,...
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based...
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based on your entities defining The attributes within each table The primary and foreign keys within each table *****Show your database tables, tables attributes, primary and foreign keys***** Do not forget to check the lesson slides and videos that show you how to convert an ER/EER into a database schema, and how to create a database and tables using MS SQL Server.
lab requires you to use Oracle VIEW to implement a virtual database on DBSEC schema, for...
lab requires you to use Oracle VIEW to implement a virtual database on DBSEC schema, for example, on CUSTOMER table. Your task is to develop a single SQL script that will perform all the following tasks: Table created for this assignment is listed below: create table CUSTOMER_VPD( SALES_REP_ID NUMBER(4), CUSTOMER_ID NUMBER(8) NOT NULL, CUSTOMER_SSN VARCHAR(9), FIRST_NAME VARCHAR(20), LAST_NAME VARCHAR(20), ADDR_LINE VARCHAR(40), CITY VARCHAR(30), STATE VARCHAR(30), ZIP_CODE VARCHAR(9), PHONE VARCHAR(15), EMAIL VARCHAR(80), CC_NUMBER VARCHAR(20), CREDIT_LIMIT NUMBER, GENDER CHAR(1), STATUS CHAR(1), COMMENTS...
Assignment 1 - IN PDF FORMAT Using R and Rstudio Pick a database from: data() Then...
Assignment 1 - IN PDF FORMAT Using R and Rstudio Pick a database from: data() Then preview the first 10 rows. Print the number of rows and columns - Print the names of the variables If you have row names, print them - work with the values for a field in your dataset. You can do it by dataset[[xx]] operator with xx can be the index of the field or the nae of the field. Now use dataset[xx] to get...
In you own words explain what relationship database is. Discuss the benefits of using relationship database...
In you own words explain what relationship database is. Discuss the benefits of using relationship database for improving workflow and efficiency of business decision-making processes.
How to tokenize a string date of format        dd/mm/yyyy into day,month and year without using built...
How to tokenize a string date of format        dd/mm/yyyy into day,month and year without using built in function of strok() or any other built in function in C++ (without classes). Kindly help Please .
You should try this code in Microsoft SQL Server to get the practice of using the...
You should try this code in Microsoft SQL Server to get the practice of using the command line and getting syntax errors. You can submit to me your sql files or just copy and paste of your code in a word document. I may try to run it, so make sure it is error free. Or you can show screen shots of code running. Write SQL CREATE Table statement to create the following table with  Owner ID  as a surrogate key.  Owner ID...
You should try this code in Microsoft SQL Server to get the practice of using the...
You should try this code in Microsoft SQL Server to get the practice of using the command line and getting syntax errors. You can submit to me your sql files or just copy and paste of your code in a word document. I may try to run it, so make sure it is error free. Or you can show screen shots of code running. Write SQL CREATE Table statement to create the following table with  Owner ID  as a surrogate key.  Owner ID...
RSQLite (using R studio) 1. Make you have imported the database tables into your database (I've...
RSQLite (using R studio) 1. Make you have imported the database tables into your database (I've copied and pasted these at the bottom). Write and submit the following RSQLite queries. 2. Retrieve the names of all employees. 3. Retrieve the names of all distinct employee names. 4. Retrieve the names of all employees whose name begins with the letter ‘B’. 5. Retrieve the names and NI numbers (NI_NO) of all employees. 6. Retrieve details of employees who are over 31...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT