Question
Hello, below is my segment of Oracle SQL statements (Highlighted in BOLD). I am trying to create statements that abide by the description in the
Hello, below is my segment of Oracle SQL statements (Highlighted in BOLD). I am trying to create statements that abide by the description in the prompt for the assignment (Which is also included below). If someone could look over my code to fix and ensure that I will get that result I would appreciate it. Thank You.
-- Create Department relation schema CREATE TABLE Department (name char(6) primary key, managerID number(3) references Employee(ID));
--Insert Data into Department Schema Insert into Department values('HR',666); Insert into Department (name) values ('RD'); Insert into Department values('SALES',222); Update Department SET managerID=888 where name='RD';
--View description of table DESCRIBE Department;
-- Create Employee relation schema CREATE TABLE Employee (ID number(3) primary key, name char(10) NOT NULL, salary number(6) NOT NULL, deptName char(6) references Department(name));
--View descrition of table DESCRIBE Employee;
-- Insert Data into Employee Schema INSERT INTO Employee VALUES(123,'John',56000,'RD'); INSERT INTO Employee VALUES(578,'Robert',37500,'HR'); INSERT INTO Employee VALUES(666,'Jenny',46000,'HR'); INSERT INTO Employee VALUES(222,'Christ',39000,'SALES'); INSERT INTO Employee VALUES(888,'Bill',50000,'RD'); INSERT INTO Employee VALUES(101,'Susan',67500,'RD');
1. Use Oracle SQL to create a script file that declares relation schemas based on the following assumptions, and then inserts data records into the relations. a) Different departments have different names. b) A department may temporarily have no manager. c) Different employees may have the same name. An employee can be uniquely identified by the ID. d) People who work in the HR department always earn at least 20,000 dollars. e) When deleting a record of an employee who is a manager, the manager ID field of the department the person works for should be set to null. f) When deleting a record of a department, the dept Name field of all employees who work in that department should be set to null. g) When changing the name of a department in relation Department, values of attribute deptName in table Employee will also be changed accordingly. For example, if 'RD' is changed to 'RESEARCH' in relation Department, all occurrences of ' RD ' in in table Employee will also to be automatically changed to 'RESEARCH'. Note: All necessary integrity constraints must be declared before any actual data is inserted into the relations. Hint: - You can add a certain constraint to a relation schema after the schema is defined. - You can insert tuples into relation Department using NULL as values of attribute managerID, and later change NULL to the IDs of assigned managers
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started