Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Lab Part (50 points Preliminary 1) Login into Linux machine (oraclelinux.eng.fau

ID: 3877101 • Letter: L

Question

Lab Part (50 points Preliminary 1) Login into Linux machine (oraclelinux.eng.fau edu) 2) Connect to database (e.g., sqlplus username/password) 3) Change line size: SET LINESIZE 400 Use Spool command to create log file for the output of SQL (e.g., SPOOL filename and SPOOL OFF) Simple SQL Queries Consider the following ER diagram. Work In work time Lab 1 (20 points) Write SQL statements (ie., DDL) that construct four relational tables, including domain (i.e data type), entity integrity (i.e., primary key), and referential integrity (i.e., foreign key). Lab 2 (20 points Write SQL statements that populate the following datasets. id 10,000,000 20,000,000 2 Sales id name 50 200,000 300,000 100,000 2 John

Explanation / Answer

below is the solution of the problem:

goto the sql prompt and type

spool c:employees.sql the spool file is below:

SQL> CREATE TABLE employees
2 (
3   id number(10) NOT NULL,
4      name varchar2(50),
5      age number(5),
6   salary number(10,3),
7      CONSTRAINT id_pk PRIMARY KEY (id)
8 );

Table created.

SQL>
SQL> CREATE TABLE departments
2 (
3   id number(10) NOT NULL,
4      name varchar2(50),
5      budget number(10,3),
6      CONSTRAINT d_id_pk PRIMARY KEY (id)
7 );

Table created.

SQL>
SQL> CREATE TABLE Works_In
2 (
3   e_id number(10) NOT NULL,
4   d_id number(10) NOT NULL,
5   work_time number(5),
6   CONSTRAINT fk_employees FOREIGN KEY (e_id) REFERENCES employees(id),
7   CONSTRAINT fk_department FOREIGN KEY (d_id) REFERENCES employees(id)
8 );

Table created.

SQL>
SQL> CREATE TABLE Dependents
2 (
3   e_id number(10) NOT NULL,
4   name varchar2(50),
5   age number(5),
6   CONSTRAINT fk_employees1 FOREIGN KEY (e_id) REFERENCES employees(id)
7 );

Table created.

SQL>
SQL> insert into employees (id,name,age,salary) values(1,'James',50,200.000);

1 row created.

SQL> insert into employees (id,name,age,salary) values(2,'Juke',55,300.000);

1 row created.

SQL> insert into employees (id,name,age,salary) values(3,'Lake',28,100.000);

1 row created.

SQL>
SQL> insert into departments (id,name,budget) values(1,'Marketing',10000.000);

1 row created.

SQL> insert into departments (id,name,budget) values(2,'Sales',20000.000);

1 row created.

SQL>
SQL> insert into Works_In (e_id,d_id,work_time) values(1,1,45);

1 row created.

SQL> insert into Works_In (e_id,d_id,work_time) values(2,2,50);

1 row created.

SQL> insert into Works_In (e_id,d_id,work_time) values(3,1,40);

1 row created.

SQL>
SQL> insert into Dependents (e_id,name,age) values(1,'Samuel',14);

1 row created.

SQL> insert into Dependents (e_id,name,age) values(1,'Daniel',17);

1 row created.

SQL> select * from employees;
SQL> select * from departments;
SQL> select * from Works_In;
SQL> select * from Dependents;
SQL> select name,salary,salary+(salary*5/100) as IncreasedSalary from employees;

NAME                                                   SALARY INCREASEDSALARY
-------------------------------------------------- ---------- ---------------
James                                                     200             210
Juke                                                      300             315
Lake                                                      100             105                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

SQL>
SQL> spool off