Schema Examples
Schema Examples
works(person-name, company-name,salary)
manages(person-name,manager-name)
The primary key for each relation is denoted by the underlined attribute.
The foreign keys are indicated by the arrow – for example, person-name in works references
person-name in lives.
When you write the queries, for brevity you can choose to use p-name, c-name, m-name for
person-name, company-name, manager-name respectively.
Relational Database Example Schemas.
There are two database schemas we will frequently use in our examples: (1) the Company
database and (2) Bank database.
1. COMPANY Database
The COMPANY database keeps track of Employees and Departments, the Projects the
Company has, and dependents of the employees (for benefits and tax purposes).
• Employees identified by SSN, Name, Location
• Department specified by Department ID (did), a department Name, Budget
• Each department has a unique manager, who is also an employee of the Company.
o The Database must keep track of starting date
• No two departments have the same name
• A person can manage at most one department
• A person can manage a department even if they do not work in the department
• Each employee works in a department
o Database must keep track of starting date
• An employee can only be assigned to one department
• A department can have zero employees
• Every employee is assigned a Supervisor (i.e, the person that directly manages the
employee).
• The Company has several Projects
o The project has a number, name, and a location for the project (For
example, Banner is a project located in Foggy Bottom.)
o Each project is controlled by a department
• Employees can be assigned to different projects. An employee can work on more
than one project.
o For accounting purposes, we need to track the number of hours an
employee works on each project they are assigned to.
• Information on Dependents of employees needs to be stored for employee
benefits purposes. The information can be social security number, name and
relationship to employee.
Schema for COMPANY database
A simplified bank database keeps track of customers, their accounts, and branch
information.