You are on page 1of 2

Systems and Database Design

Data Dictionary for “company” Database

This data dictionary details the database used for lecture examples and workshop tasks in Systems
and Database Design. Use it to gain a better understanding of the database structure, and as an
example of a data dictionary when creating your own in Assignment 2. Module 4 introduces data
dictionaries, Module 6 covers data types, and Module 7 covers constraints and other column details.

“region” table (stores details about regions)


Column Name Data Type & Length Null Constraints Other
region_id TINYINT NOT NULL PK IDENTITY
region_name VARCHAR(25) NOT NULL UNIQUE

“country” table (stores details about countries)


Column Name Data Type & Length Null Constraints Other
country_id CHAR(2) NOT NULL PK
country_name VARCHAR(50) NOT NULL UNIQUE
region_id TINYINT NOT NULL FK (region.region_id)

“location” table (stores details about locations)


Column Name Data Type & Length Null Constraints Other
location_id SMALLINT NOT NULL PK IDENTITY
street_address VARCHAR(50) NOT NULL
postal_code VARCHAR(15) NOT NULL
city VARCHAR(30) NOT NULL
state_province VARCHAR(25) NOT NULL
country_id CHAR(2) NOT NULL FK (country.country_id)

“job” table (stores details about jobs)


Column Name Data Type & Length Null Constraints Other
job_id VARCHAR(10) NOT NULL PK
job_title VARCHAR(50) NOT NULL UNIQUE
min_salary MONEY NOT NULL DEFAULT 1000
max_salary MONEY NULL
Table Level Constraints:
 CHECK (max_salary > min_salary)

“department” table (stores details about departments)


Column Name Data Type & Length Null Constraints Other
department_id SMALLINT NOT NULL PK IDENTITY(10, 10)
department_name VARCHAR(25) NOT NULL
manager_id INT NULL FK (employee.employee_id)
location_id SMALLINT NOT NULL FK (location.location_id)
Note that the manager_id FK constraint will be created after the department and employee tables have been created and populated.

“employee” table (stores details about employees)


Column Name Data Type & Length Null Constraints Other
employee_id INT NOT NULL PK IDENTITY
first_name VARCHAR(25) NOT NULL
last_name VARCHAR(25) NOT NULL
gender CHAR(1) NULL CHECK (gender IN ('M', 'F'))
email VARCHAR(25) NOT NULL UNIQUE
phone_number VARCHAR(20) NOT NULL
hire_date DATE NULL
job_id VARCHAR(10) NOT NULL FK (job.job_id)
salary MONEY NOT NULL CHECK (salary > 0)
commission_pct NUMERIC(2,2) NULL
manager_id INT NULL FK (employee.employee_id)
department_id SMALLINT NULL FK (department.department_id)
Table Level Constraints:
 CHECK (employee_id != manager_id)

“job_history” table (stores details about prior jobs held by employees in the company)
Column Name Data Type & Length Null Constraints Other
employee_id INT NOT NULL FK (employee.employee_id)
start_date DATE NOT NULL
end_date DATE NOT NULL
job_id VARCHAR(10) NOT NULL FK (job.job_id)
department_id SMALLINT NULL FK (department.department_id)
Table Level Constraints:
 PRIMARY KEY (employee, start_date)
 CHECK (end_date > start_date)

“job_grade” table (stores details about the grade levels used by the company)
Column Name Data Type & Length Null Constraints Other
grade_level CHAR(1) NOT NULL PK
lowest_sal MONEY NOT NULL
highest_sal MONEY NOT NULL
Table Level Constraints:
 CHECK (highest_sal > lowest_sal)

You might also like