0% found this document useful (0 votes)
94 views27 pages

Assignment Cse311

Uploaded by

Shakil Ahmed
The document describes the data requirements for a company database. The company has branches, employees, clients, and suppliers. Entities in the database include employees, branches, clients, and the relationship between branches and suppliers. The document also includes sample data for the tables and queries to retrieve information from the tables.

Copyright:

© All Rights Reserved

Available Formats

Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
94 views27 pages

Assignment Cse311

Uploaded by

Shakil Ahmed
The document describes the data requirements for a company database. The company has branches, employees, clients, and suppliers. Entities in the database include employees, branches, clients, and the relationship between branches and suppliers. The document also includes sample data for the tables and queries to retrieve information from the tables.

Copyright:

© All Rights Reserved

Available Formats

Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 27

NORTH SOUTH

UNIVERSITY

Cse311
project
company data requirements

SUBMITTED BY
NAME: SHAKIL AHMED

ID: 1712081642

Sec: 5

SUBMITTED TO
NDA
Index

1.Project name & description: page:2

2.Er diagram: page:3

3.Schema diagram : page:4

4.Query & Picture of table data: Page: 5-22

6.Apendix: Page: 22-26

Company Data Requirements


The company is organised into branches. Each branch has a unique number, a name, and
a particular employee who manages it. The company makes it’s money by selling to clients.
Each client has a name and a unique number to identify it. The foundation of the company
is it’s employees. Each employee has a name, birthday, sex, salary and a unique number.
An employee can work for one branch at a time, and each branch will be managed by one
of the employees that work there. We will also want to keep track of when the current
manager started as manager. An employee can act as supervisor for other employees at
other branches. An employee can have at most one supervisor. A branch may handle a
number of clients, with each client having a name, a unique number to identify it. A single
client may only be handled by one branch at a time. Employees can work with clients
controlled by their branch to sell them stuff. If necessary multiple employees can work
with the same client. We will want to keep track of how many dollars worth of stuff each
employee sells o each client they work with. Many branches will need to work with
suppliers to buy inventory for each supplier we will keep track of their name and type of
product they are selling the branch. A single supplier may supply products to multiple
branches.

Entities:

Employee

Branch

Client

Branch Supplier

Works on
Query
SELECT * FROM employee1

SELECT * FROM branch_supplier


Find Annual Salary:
SELECT last_name “Name”, salary*12 “Annual Salary”

FROM employee1

Find employee’s Id & Last name:


SELECT CONCAT (last_name, " ’s id ", emp_id) "Employee Details"

From employee1
SELECT last_name

FROM employee1

WHERE salary >(SELECT salary

FROM employee1

WHERE last_name = 'Scott')


SELECT last_name, emp_id, branch_id

FROM employee1

WHERE last_name = 'Ahmed'


SELECT last_name, super_id, sex

FROM employee1

ORDER BY salary DESC


SELECT last_name, salary

FROM employee1

WHERE salary BETWEEN 75000 AND 200000


SELECT emp_id, last_name, salary, super_id

FROM employee1

WHERE super_id IN (102, 101, 108)


SELECT * FROM works_with
SELECT AVG(salary), MAX(salary),

MIN(salary), SUM(salary)

FROM employee1

WHERE last_name LIKE '%med'


SELECT e.last_name, e.branch_id, d.branch_name

FROM employee1 e

RIGHT OUTER JOIN branch d

ON e.branch_id = d.branch_id
SELECT last_name

FROM employee1

WHERE last_name LIKE '_o%'


SELECT e.emp_id, e.last_name, e.branch_id, d.branch_id

From employee1 e JOIN banch d

ON (e.branch_id = d.branch_id)

AND e.super_id = 108


PAYROLL CHECK:

SELECT emp_id, SUM(salary) PAYROLL

FROM employee1

WHERE emp_id NOT LIKE '%8%'

GROUP BY emp_id

HAVING SUM(salary) > 130000

ORDER BY SUM(salary)
Function:

SELECT (MAX(salary))

FROM employee1

GRPOUP BY branch_id
Update:

update employee1

set salary = salary * 1.03

where salary > 180000

update employee1

set salary = salary * 1.05

where salary <= 50000;


Delete:

delete from employee1

where salary > 100000;


Appendix

CREATE TABLE employee1(

emp_id varchar (50),

first_name varchar (20),

last_name varchar (20),

birth_date DATE NOT null,

sex char (10),

salary Decimal (8,2),

super_id varchar (30),

branch_id varchar (30)

);

INSERT INTO
employee1(emp_id,first_name,last_name,birth_date,sex,salary,super_id,branch_id)

VALUES ('100', 'Jon', 'Levinson', '1961-05-11', 'M', '110000', '108', '1'),

('101', 'Michel', 'Scott', '1964-03-15', 'M', '75000', '100', '2'),

('102', 'Josh', 'Porter', '1969-09-05', 'M', '78000', '100', '3'),

('103', 'Angela', 'Martin', '1971-06-25', 'F', '63000', '101', '2'),

('104', 'Andy', 'Bernerd', '1973-07-22', 'M', '65000', '102', '3'),

('105', 'Jim', 'Helperd', '1968-04-11', 'M', '69000', '102', '3'),

('106', 'Kelly', 'Kapoor', '1988-02-23', 'F', '80000', '101', '2'),

('107', 'Stanly', 'Hudson', '1980-04-22', 'M', '100000', '101', '2'),

('108', 'David', 'Walace', '1967-08-11', 'M', '98000', '101', '1'),

('109', 'Sumi', 'Akter', '1990-10-10', 'F', '40000', '100', '3'),


('110', 'Anik', 'Ahmed', '1992-11-18', 'M', '230000', 'NULL', '1')

CREATE TABLE branch(

branch_id varchar (30),

branch_name varchar (40),

mgr_id varchar (20),

mgr_start_date DATE NOT NULL

);

INSERT INTO branch(branch_id, branch_name, mgr_id, mgr_start_date)

VALUES ('2', 'Scranton', '101', '1992-04-06'),

('3', 'Stamford', '102', '1988-02-13'),

('1', 'Corporate', '108', '2002-10-18')

CREATE TABLE client(

client_id varchar (30),

client_name varchar (40),

branch_id varchar (30)

);

INSERT INTO client(client_id, client_name, branch_id)

VALUES ('400', 'Dunmore Highschool', '2'),

('401', 'Lackawana Country', '3'),

('402', 'FedEx', '3'),

('403', 'Jhon Daly Law LLC', '3'),


('404', 'Scranton Whitepages', '2'),

('405', 'Times Newspaper', '3'),

('406', 'Apex Co.', '2')

CREATE TABLE works_with(

emp_id varchar (50),

client_id varchar (30),

total_sales decimal (8,2)

);

INSERT INTO works_with(emp_id, client_id, total_sales)

VALUES ('107', '400', '55000'),

('103', '402', '300000'),

('110', '405', '200000'),

('106', '406', '82000'),

('102', '401', '40000'),

('109', '400', '47000'),

('104', '403', '63000'),

('100', '404', '80000'),

('105', '405', '32000'),

('101', '406', '39000'),

('108', '402', '50000')

CREATE TABLE branch_Supplier(


branch_id varchar (30),

supplier_name varchar (30),

supplier_type varchar (25)

);

INSERT INTO branch_Supplier(branch_id, supplier_name, supplier_type)

VALUES ('2', 'Hammer Mill', 'paper'),

('2', 'Uni-ball', 'Writing Utencils'),

('3', 'Patriot Paper', 'paper'),

('2', 'J.T Forms & Labels', 'Custom Forms'),

('3', 'Uni-ball', 'Writing Utencils'),

('3', 'Apex', 'shoe'),

('3', 'Stamford Labels', 'Custom Forms')

You might also like