Use SQL statements to create all six tables from the NamanNavan (N2) Corporation database in Chapter 3. If you have already created a DEPT table in Chapter 3’s Lab Activity, you will skip it. Define the primary key, foreign key, NOT NULL, DEFAULT, CHECK, and UNIQUE constraints in the CREATE TABLE statement. If not possible, use ALTER TABLE statement to add a constraint. (Remember: Foreign key constraint requires existence of the referenced table). Spool your statements and results to the CH4LAB2.LST file and print each table’s structure and constraints as well.

What will be an ideal response?


CREATE TABLE emplevel
```
(LevelNo NUMBER (1),
LowSalary NUMBER (6),
HighSalary NUMBER (6),
CONSTRAINT emplevel_levelno_pk PRIMARY KEY (LevelNo));
```

CREATE TABLE position
```
(PositionId NUMBER (1),
PosDesc VARCHAR2 (10),
CONSTRAINT position_positionid_pk PRIMARY KEY (PositionId));
```

CREATE TABLE qualification
```
(QualId NUMBER (1),
QualDesc VARCHAR2 (11),
CONSTRAINT qualification_qualid_pk PRIMARY KEY (QualId));
```

CREATE TABLE dept
```
(DeptId NUMBER (2),
DeptName VARCHAR2 (12) NOT NULL,
Location VARCHAR2 (15),
EmployeeId NUMBER (3),
CONSTRAINT dept_deptid_pk PRIMARY KEY (DeptId));
```

CREATE TABLE employee
```
(EmployeeId NUMBER (3),
Lname VARCHAR2 (15) CONSTRAINT employee_lname_nn NOT NULL,
Fname VARCHAR2 (15) CONSTRAINT employee_fname_nn NOT NULL,
PositionId NUMBER (1),
Supervisor NUMBER (3),
HireDate DATE,
Salary NUMBER (6),
Commission NUMBER (5),
DeptId NUMBER (2) NOT NULL,
QualId NUMBER (1),
CONSTRAINT employee_employeeid_pk
PRIMARY KEY (EmployeeId),
CONSTRAINT employee_positionid_fk FOREIGN KEY (PositionId)
REFERENCES position (PositionId),
CONSTRAINT employee_deptid_fk FOREIGN KEY (DeptId)
REFERENCES dept (DeptId),
CONSTRAINT employee_qualid_fk FOREIGN KEY (QualId)
REFERENCES qualification (QualId));
```

CREATE TABLE dependent
```
(EmployeeId NUMBER (3),
DependentId NUMBER (1),
DepDOB DATE,
Relation VARCHAR2 (8),
CONSTRAINT dependent_empiddepid_pk PRIMARY KEY (EmployeeId, DependentId),
CONSTRAINT dependent_employeeid_fk FOREIGN KEY (EmployeeId)
REFERENCES employee (EmployeeId));

DESCRIBE
SELECT CONSTRAINT_NAME, CONSTRAINT_TYPE , TABLE_NAME
FROM USER_CONSTRAINTS ORDER BY TABLE_NAME;
```

Computer Science & Information Technology

You might also like to view...

Which of the following is correct regarding presence and behavior of constructor is correct. Assume that the class name is C.

a. To use the declaration, C x; requires a default constructor must be present. b. To invoke the default constructor, the syntax must be C x(); c. A constructor is called automatically when you declare an object of class type, but any constructor can be called after declaration to set all the member variables to a known state. d. An explicit call to a constructor creates an anonymous object, which can be assigned. e. In spite of the fact that a constructor appears to be a member function, a constructor may not be called as if it were a member function

Computer Science & Information Technology

Company A has 500 employees. Company B has 800 employees. Would the analyst working with company B need to interview more employees than the analyst working with Company A? Why or why not?

What will be an ideal response?

Computer Science & Information Technology

Write a method called alarm that prints the string "Alarm!" multiple times on separate lines. The method should accept an integer parameter that specifies how many times the string is printed. Print an error message if the parameter is less than 1.

What will be an ideal response?

Computer Science & Information Technology

?Which of the following examples tests whetherxis equal to 5 oryis equal to 8?

A. ?(x === 5) && (y === 8) B. ?(x === 5) : (y === 8) C. ?(x === 5) || (y === 8) D. ?(x === 5) / (y === 8)

Computer Science & Information Technology