Question

In: Computer Science

Question (1) Answer each of the following questions briefly. These questions are based on the following...

Question (1) Answer each of the following questions briefly.

These questions are based on the following relational schema:
Emp(eid: integer, ename: string, age: integer, salary: real)
Works(eid: integer, did: integer, pcttime: integer)
Dept(did: integer, dname: string, budget: real, managerid: integer)
(a) (5 points) Give an example of a foreign key constraint that involves the Dept relation. What are the options for enforcing this constraint when a user attempts to delete a Dept tuple?
(b) (5 points) Write the SQL statements required to create the preceding relations, including appropriate versions of all primary and foreign key integrity constraints.
(c) (5 points) Define the Dept relation in SQL so that every department is guaranteed to have a manager.
(d) (5 points) Write an SQL statement to add John Doe as an employee with eid = 101, age = 32 and salary = 15, 000.
(e) (5 points) Write an SQL statement to give every employee a 10 percent raise.
(f) (5 points) Write an SQL statement to delete the Toy department. Given the referential integrity constraints you chose for this schema, explain what happens when this statement is executed.

**I am using Oracle SqlPlus**

Solutions

Expert Solution

**I request you to Please Provide the positive Rating**

Answer each of the following questions

Emp(eid: integer, ename: string, age: integer, salary: real)

Works(eid: integer, did: integer, pcttime: integer)

Dept(did: integer, dname: string, budget: real, managerid: integer)

(a) (5 points) Give an example of a foreign key constraint that involves the Dept relation. What are the options for enforcing this constraint when a user attempts to delete a Dept tuple?

ANSWER) DID IS THE FOREIGN KEY IN THE WORKS TABLE.

CREATE TABLE WORKS(eid  integer, did  integer, pcttime  integer, FOREIGN KEY eid REFERENCES Emp(eid ), FOREIGN KEY DID REFERENCES DEPT(DID))

CREATE TABLE DEPT(did integer, dname VARCHAR(200), budget  real, managerid integer, PRIMARY KEY(DID))

(b) (5 points) Write the SQL statements required to create the preceding relations, including appropriate versions of all primary and foreign key integrity constraints.

ANSWER) CREATE TABLE Emp(eid integer, ename VARCHAR(200), age integer, salary real,PRIMARY KEY (EID))

CREATE TABLE WORKS(eid  integer, did  integer, pcttime  integer, FOREIGN KEY eid REFERENCES Emp(eid ), FOREIGN KEY DID REFERENCES DEPT(DID))

CREATE TABLE DEPT(did integer, dname VARCHAR(200), budget  real, managerid integer, PRIMARY KEY(DID))

(c) (5 points) Define the Dept relation in SQL so that every department is guaranteed to have a manager.

CREATE TABLE DEPT(did integer, dname VARCHAR(200), budget  real, managerid integer NOT NULL, PRIMARY KEY(DID))

d) (5 points) Write an SQL statement to add John Doe as an employee with eid = 101, age = 32 and salary = 15, 000.

INSERT INT EMP(101,"John Doe",32,15000);

(e) (5 points) Write an SQL statement to give every employee a 10 percent raise.

UPDATE EMP SET SALARY=SALARY+(0.1*SALARY) ;

(f) (5 points) Write an SQL statement to delete the Toy department. Given the referential integrity constraints you chose for this schema, explain what happens when this statement is executed.

DELETE FROM DEPT WHERE DNAME="TOY";

when this statement is executed, it will delete all the roes which have the department name as 'toy'


Related Solutions

1.Answer each of the following questions (4 POINT EACH) A. Identify and briefly describe the five...
1.Answer each of the following questions (4 POINT EACH) A. Identify and briefly describe the five factors that make up the Big Five Model, and then identify the trait approach that this model falls within. B. Explain each side of the Person-Situation Debate (i.e., provide the main argument from each side of the debate). Describe the interactionist point of view in this debate as well.
. Answer the following questions briefly, based on your understanding of the common shapes of cost...
. Answer the following questions briefly, based on your understanding of the common shapes of cost curves. Where will the marginal cost curve cross the average cost curve? Why? Will the total cost curve tend to flatten out or to slope up more steeply on the right? Why? Why are total costs and marginal costs not usually shown on the same graph together? What are the underlying economic reasons that short-run average cost typically slope down then up? Will average...
Discuss each question in 1-2 paragraphs. Answer the questions in “answer and question format”, that is,...
Discuss each question in 1-2 paragraphs. Answer the questions in “answer and question format”, that is, when you are posting, include both the questions and your answers. What are some challenges associated with working conditions in a globalized economy that effect US workers?
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as possible: What is a checked exception, and what is an unchecked exception? What is NullPointerException? Which of the following statements (if any) will throw an exception? If no exception is thrown, what is the output? 1: System.out.println( 1 / 0 ); 2: System.out.println( 1.0 / 0 ); Point out the problem in the following code. Does the code throw any exceptions? 1: long value...
Question 1: The following table to answer the following questions.
Question 1: The following table to answer the following questions.  a. Sketch the aggregate supply(s) and aggregate demand diagram(s). b. What is the equilibrium output and price level? c. If aggregate demand shifts right, what is long-run equilibrium output? d. If aggregate demand shifts left, what is equilibrium long-run output? e. For an economy at long-run equilibrium, would you suggest using aggregate demand to alter the level of output or to control any inflationary increases in the price level? Why?
QUESTION 1 Study the information given below and answer each of the following questions independently: •          ...
QUESTION 1 Study the information given below and answer each of the following questions independently: •           Calculate the margin of safety (as a percentage). •           Calculate the number of units that must be sold if the company desires an operating profit of $1 350 000. •           Suppose the company wants to spend $120 000 more on advertising and reduce the selling price by $4 per unit, with the expectation that the sales volume will increase by 20%. Is this a...
Please answer the following questions based on Chipotle: • Section One – Background/Introduction Briefly give a...
Please answer the following questions based on Chipotle: • Section One – Background/Introduction Briefly give a background of the company and introduction to your paper • Section Two – Core Competencies Identify Chipotle’s core competencies and discuss with supporting research • Section Three—Value Chain Identify and discuss the primary and secondary components of Chipotle’s value chain •Section Four – Competitive Strategy Pick, research and discuss one of the five generic competitive strategies most that most closely approximates the competitive approach...
Please answer the following questions. (1-2 paragraphs for each question). 1.)What are the industry attributes of...
Please answer the following questions. (1-2 paragraphs for each question). 1.)What are the industry attributes of Realty Income Corporation? Briefly describe any attributes of the industry that have a major effect on the performance of Realty Income Corporation. For example, what factors affect demand for the company's product? 2.) Has Realty Income Corporation been profitable over the last 3 years? Have profits increased or decreased? Perform a DuPont Analysis.
Answer the following questions: Question 1: Why is it important to carefully read each email before...
Answer the following questions: Question 1: Why is it important to carefully read each email before sending it? Questions 2: Name three examples of communication technology commonly used in corporate communications
For each of the following questions, give the correct answer. However, don't just answer the question....
For each of the following questions, give the correct answer. However, don't just answer the question. For each answer choice, you have to provide at least a paragraph response on why that answer choice is correct or incorrect with relevant and outside information. Celery stalks that are immersed in fresh water for several hours become stiff and hard. Similar stalks left in a salt solution become limp and soft. From this we can deduce that the cells of the celery...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT