israr dbms assigment
israr dbms assigment
1
(Taken from Exercise 5.15)
Consider the following relations for a database that keeps track of student enrollment in courses and the books adopted
for each course:
Task:
1. Draw a relational schema diagram specifying the foreign keys for this schema.
Solution:
Step 1: Creating the Database
CREATE DATABASE enroll;
The STUDENT table links to ENROLL through SSN, COURSE links to ENROLL through COURSENO, TEXT links to
BOOK_ADOPTION through Book_ISBN, and BOOK_ADOPTION links back to COURSE through COURSENO.
Question No. 2
In this task, I designed and populated a database schema for a company named `company_Israr`, covering essential
aspects of company operations. The schema includes six key tables: **EMPLOYEE**, **DEPARTMENT**,
**DEPT_LOCATIONS**, **PROJECT**, **WORKS_ON**, and **DEPENDENT**. Each table models different
elements, such as employee information, departmental data, project assignments, and employee dependents. Here’s a
breakdown of each table and its function:
2. **EMPLOYEE Table:**
- This table holds each employee's details, including personal information (first and last names, social security
number, birthdate, address, gender, and salary).
- `Super_ssn` links to an employee’s supervisor, and `Dno` is a foreign key that associates the employee with a
specific department in the `DEPARTMENT` table.
- `FOREIGN KEY (Super_ssn) REFERENCES EMPLOYEE(Ssn)` allows for a recursive relationship, where an
employee can have another employee as their supervisor.
3. **DEPARTMENT Table:**
- Contains information on company departments, such as department name (`Dname`), department number
(`Dnumber`), manager’s SSN (`Mgr_ssn`), and the manager's start date.
- `FOREIGN KEY (Mgr_ssn) REFERENCES EMPLOYEE(Ssn)` links each department to its manager in the
`EMPLOYEE` table.
4. **DEPT_LOCATIONS Table:**
- Tracks department locations, with `Dnumber` as a foreign key linking it to the `DEPARTMENT` table.
- The combination of `Dnumber` and `Dlocation` forms a composite primary key, allowing departments to have
multiple locations.
5. **PROJECT Table:**
- Records details about company projects, including project name (`Pname`), project number (`Pnumber`), location
(`Plocation`), and the department in charge (`Dnum`).
- `Dnum` is a foreign key that links each project to a department in the `DEPARTMENT` table.
6. **WORKS_ON Table:**
- Captures the allocation of employees to projects, with fields for employee SSN (`Essn`), project number (`Pno`), and
hours worked on each project.
- `Essn` references the `EMPLOYEE` table, and `Pno` references the `PROJECT` table. Both `Essn` and `Pno` form a
composite primary key since employees can work on multiple projects.
7. **DEPENDENT Table:**
- Stores details about employees’ dependents, including the employee’s SSN (`Essn`), dependent’s name
(`Dependent_name`), gender, birth date (`Bdate`), and relationship to the employee.
- `Essn` serves as a foreign key referencing the `EMPLOYEE` table, associating each dependent with an employee.
Sample data for each table illustrates how records would appear within the schema, with relationships defined through
primary and foreign keys to simulate real-world connections, such as employees belonging to departments, working on
projects, and having dependents. This schema supports effective data management and querying for organizational
functions.