0% found this document useful (0 votes)
44 views3 pages

M2-Activity No. 3

The document provides the schema and requirements for creating an Employee database. Part 1 introduces the database schema with Department, Employees, and Salary_Grade tables. Part 2 lists 10 requirements for creating the tables such as auto-incrementing primary keys, check constraints on columns, and default values. Part 3 requires screenshots showing the created database design as evidence it was implemented.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views3 pages

M2-Activity No. 3

The document provides the schema and requirements for creating an Employee database. Part 1 introduces the database schema with Department, Employees, and Salary_Grade tables. Part 2 lists 10 requirements for creating the tables such as auto-incrementing primary keys, check constraints on columns, and default values. Part 3 requires screenshots showing the created database design as evidence it was implemented.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

UNIVERSITY OF THE EAST

Manila
COLLEGE OF COMPUTER STUDIES AND SYSTEMS

CIM 1101: Information Management

Name: Aranilla, Althird Cherson T. Activity Number: 3


Section: ITCC Activity Name: Creating
Database/Tables

Part 1:

Given the database schema of employee below, create the database design using SQL
statements.

Part 2:

List all the SQL commands needed in creating the database. Consider the following:

1. Dep_id of department table is an auto-increment starts at 100, interval of 10.


2. Limit the dep_name to these values: PAYROLL, PURCHASING, ACCOUNTING,
HR. (REQUIRED)
3. Min_salary should not greater than 9999. (REQUIRED)
4. Max_salary should be greater than 9999. (REQUIRED)
5. Limit values for job_name to SUPERVISOR, MANAGER, TEAM-LEAD,
ASSISTANT. Default: ASSISTANT. (REQUIRED)
6. Manager_id should have a default value of 200.
7. Hire_date should get the current date by default.
8. Salary should be more than greater than 10,000 and default value is 10000.01.
(REQUIRED)
9. Grade from salary table is an auto-increment starts at 10, interval is 2.
10. Input 3 records each table.

Part 3:

As evidence that database design has been created, include screenshots of your entire
window/screen showing the created database design.

YOUR ANSWERS HERE....

create database Employee;


use Employee;

create table Department(


dep_id int IDENTITY(100,10),
dep_name varchar(20) CHECK (dep_name = 'PAYROLL' or dep_name = 'PURCHASING' or
dep_name = 'ACCOUNTING' or dep_name = 'HR') NOT NULL,
dep_location varchar(15),
PRIMARY KEY (dep_id)
);
drop table Department;

create table employees(


emp_id int,
emp_name varchar(15),
job_name varchar(10) DEFAULT 'ASSISTANT' CHECK (job_name = 'SUPERVISOR' or
job_name = 'MANAGER' or job_name = 'TEAM-LEAD' or job_name = 'ASSISTANT') NOT NULL,
manager_id int DEFAULT 200,
hire_date date DEFAULT getdate(),
salary decimal(10,2) CHECK (salary>10000) DEFAULT 10000.01,
commission decimal(7,2),
dep_id int FOREIGN KEY REFERENCES Department(dep_id),
PRIMARY KEY (emp_id)
);
drop table employees;

create table salary_grade(


grade int IDENTITY(10,2),
min_salary int CHECK (min_salary<9999) NOT NULL,
max_salary int CHECK (max_salary>9999) NOT NULL,
PRIMARY KEY (grade)
);
drop table salary_grade;

insert into Department(dep_name) VALUES ('Payroll');


insert into Department(dep_name, dep_location) VALUES ('purchasing', 'quezon city');
insert into Department VALUES ('ACCOUNTING', 'pasig');

insert into employees(emp_id, emp_name, job_name, salary, commission) VALUES (1, 'Mikee',
'Manager', 20000, 1000);
insert into employees(emp_id, emp_name, job_name, salary, commission) VALUES (2, 'Carlo',
'ASSISTANT', 15000, 1000);
insert into employees(emp_id, emp_name, job_name, salary, commission) VALUES (3,
'Maymay', 'supervisor', 18000, 1000);

insert into salary_grade(min_salary, max_salary) VALUES (9000, 100000);


insert into salary_grade(min_salary, max_salary) VALUES (5000, 100000);
insert into salary_grade(min_salary, max_salary) VALUES (4000, 100000);

select * from Department;


select * from employees;
select * from salary_grade;

You might also like