database project group 5
database project group 5
SECTION A
1. TESFAYE ABERA……..…..1501343
2. SISAY KEBEDE……………1501279
3. TSEDEKE WONDIMU..…1510032
4. SHIMELIS HAILU…..…….1501271
5. SETELIGN MELESE………1501262
SUMMITED TO
MS.FOZIA
Contents page
ACKNOWLEDGEMENT 1
1
1 Introduction 2
2 Objective 3
4 Methodology 5
6 Design 6
7.1 ER - diagram 8
8 Implementation 18
ACKNOWLEDGEMENT
Firstly we would like to express our priceless gratitude to our instructor Md. fozia for his willingness to
giving us this chance to work on this project because this project made us understand more about this
course. And also for all peoples who contribute in this project we would like to say thank you.
1 Introduction
The sun shine super market gives fundamental uses to the society .in the previous time it works based on
manual approach of data handling. This makes very tidies to manipulate the data.so we tried to change this
system to database approach ,in order to reduce data redundancy and to store our file in safe and secured
place by locating database.
2
2.Objective
The main objective of our project is to develop a database system for sun shine super market.
This project focus on only in development a system for sun shine supermarket with many advanced futures
that reduces time, effort and improve the way of money transaction for the supermarket.
3
implementation of the project
fundamental concept
4 Methodology
we model the entities and other actors of the system using E-R modeling
Relational model must be used and we have selected the SQL server 2008 software.
The language we will use is SQL (structured query language) because it has so many features and easy to
understand.
Customer :is the important person who purchase item from the supermarket
Cashier: is the person who registers the item and give bill to the customer.
Process: the overall process that takes place in the supermarket concerning the item are:
4
the cashier checks the item is expired or not and checks the item is completed or not.
bill papers.
6.Design
7.1ER diagram
5
7.2 Description of the entity
6
employee: - Have an attributes
- It has an attribute of item name , item code, item type, quantity ,state ,exp_date,
- And a multivalued attribute of price that is cost price and sell price
7
DOB
- It has a relation with managers
- It has supply item in a supplied date
One-to-one
One-to-many
Manager with employee:-one manager manages one or more employee in the super market
Cashier: one cashier can print bill for one or more customer
Many-to-many
Customer with item: this means many customers buy one or more items or one item is bought by one or more
customer
Employee with item:this means many employees sell one or more items or one item is sold by one or more
employee
Employee with customer: this means many employee give service to one or more customer
There will be Manager table with Man_id, dob, age, and sex being the columns.
multi-valued
Manager
8
Man_email
Man_id email
Man_Phone_number
Man_id Phone_no
Customer
Cust_Phone_number
Cust_id Phone_no
Employee
Emp_Phone_number
Cust_id Phone_no
Cashier
Cash_Phone_number
Cust_id Phone_no
Managed
9
Item
suplier
Phone_number
sup_id Phone_no
sup_id email
Supplies
Buys
Sells item
emp_id Item_code Sell date
10
Emp_id Cust_id cust_id emp_id Bill_no
Man_id Sup_id
database schema
Manager
Phon number
man_id Phon_no
Man_id email
Managed
Customer
Print_bill
11
cust_id Cas_id Bill_no
cashier
Phone num
Cash_id Phon_no
Register_new item
employee
Phone number
Emp_id Phone_no
Give service
Emp_id Cust_id
Sells ite
Emp_id Item_code
Item
12
Item_code Item_name Item_type Sell_price Cost_price State Quantity Exp-date
suplier
Phone_no
Sup_id Phone_no
Sup_id Email
Supplies
Sup_id Item_code Supply_date
buys
cust_id Item_code
request
Man_id Sup_id
8. Implementation
13
Sex char(5),
Constraint ck_sx check (sex in('f','m','female','male')),
Dob date,
Age int,
Phone_no varchar(13)
)
-----------------employee tabee----------------
-----------------manager table--
Create table manager
(
Man_id varchar(20)not null primary key,
Fname varchar(20),
Lname varchar(20),
Sex varchar(5),
Dob date,
Age int,
Phone_no varchar(13),
Email varchar(13)
)
-----------------cashier table----------------
Create table cashier
(
14
Cost_price float,
Sell_price float,
Exp_date date,
States varchar(20),
)
-----------------suplier table----------------
15
(
Mman_id varchar(20)not null foreign key references manager(man_id),
Memp_id varchar(20)not null foreign key references employee(emp_id),
Mcash_id varchar(20)not null foreign key references cashier(cash_id),
income money,
sold_item int
)
-----------------request table----------------
create table request
(
rman_id varchar(20)not null foreign key references manager(man_id),
rsup_id varchar(20)not null foreign key references suplier(sup_id),
)
-----------------supply table----------------
create table supply
(
suitem_code varchar(20)not null foreign key references Item(Item_code),
susup_id varchar(20)not null foreign key references suplier(sup_id),
supply_date date
)
-----------------register table----------------
Create table rigister
(
rrcash_id varchar(20)not null foreign key references cashier(cash_id),
rritem_code varchar(20)not null foreign key references Item(Item_code)
)
-------------------------populate data----------------------------
------customer-----
insert into custumer
values('cu001','Dagim','Bekele','m','12/04/1994',21,'+250936587441')
insert into custumer
values('cu002','ale','belete','m','12/04/1994',21,'+25196588485')
insert into custumer
values('cu003','bete','wasie','f','12/04/1995',20,'+251936458752')
insert into custumer
values('cu004','wale','beke','m','12/04/1994',21,'+251956842369')
insert into custumer
values('cu005','leli','wale','m','12/04/2004',11,'+251945698712')
insert into custumer
values('cu006','mesi','adhenafi','f','12/04/1970',47,'+25111112354')
insert into custumer
values('cu007','belete','mele','m','12/04/1965',52,'+25111456589')
insert into custumer
values('cu009','ayalew','welelaw','m','12/04/1970',47,'+25111661123')
insert into custumer
values('cu008','betelehem','medihin','f','12/04/1994',21,'+251918969791')
insert into custumer
values('cu0010','belachew','belete','m','12/04/1994',21,'+251918969763')
16
select fname,lname from custumer where Sex='f'
select fname,lname from custumer where Sex='m'
select year(Dob)as dob,year((select getdate()))asnow,year((select
getdate()))-year(dob)as age from custumer
-----------casher----------
----------gives bill---------
------employee-----
insert into employee
values('emp001','betelehem','medihin','f','12/04/1994',21,'+251918969791'
)
insert into employee
values('emp002','belachew','belete','m','12/04/1994',21,'+251918969763')
----------------------employee-----------------------------
select*from employee
select emp_id,fname,sex,dob,phone_no from employee
select dob,age from employee
select year(Dob)as dob,year((select getdate()))asnow,year((select
getdate()))-year(dob)as age from employee
------manager-----
insert into manager
values('man002','kedus','fekadu','m','12/04/1970',23,'+251911114521','man
@gmal.com')
------suplier-----
insert into suplier
values('sup002','balw','yibe','m','12/04/1970',23,'+251911114521','own@gm
al.com','gonder')
insert into suplier
values('sup001','balw','yibe','m','12/04/1970',23,'+251911114521','man@gm
al.com','adis abebe')
--------------------------manager---------------------
select*from manager
select man_id,fname,Sex from manager
select man_id,phone_no,email from manager
select man_id,dob from manager
select dob,age from manager
select year(Dob)as dob,year((select getdate()))asnow,year((select
getdate()))-year(dob)as age from suplier
----------------------suplier-----------------------------
17
select*from suplier
select sup_id,fname,Sex,city from suplier
select sup_id,phone_no,email from suplier
select sup_id,dob from suplier
select dob,age from suplier
select year(Dob)as dob,year((select getdate()))asnow,year((select
getdate()))-year(dob)as age from suplier
------item-----
insert into Item
values('it002','pepsi','food',23,23.4,44.8,'12/04/2016','liquid')
insert into Item
values('it001','bread','food',23,23.9,44.4,'11/04/2016','solid')
insert into Item
values('it0078','checolet','food',23,2.7,4.4,'12/04/2016','solid')
insert into Item
values('it006','milk','food',23,2.3,4.9,'2/01/2019','liquid')
insert into Item
values('it009','bread','food',23,8.3,44,'12/06/2016','solid')
----------------------item-----------------------------
select*from Item
select Item_code,Item_name,Item_type,Sattus from Item where
Item_type='food'and Sattus='solid'
select Item_code,Item_name,Item_type,Sattus from Item where
Item_type='deteregent'and Sattus='gas'
select Item_code,Item_name,Item_type,Sattus from Item where
Item_type='cosmotics'and Sattus='liquid'
select Item_code,Item_name,exp_date from Item
select*from Item where Quantity<10
select Item_name from Item where quantity>10 and Exp_date<(select
GETDATE())
select Item_code,cost_price from Item
select Item_code,Item_name,Cost_price*quantity as
total_price_of_each_item from Item
select Item_code,Item_name,sell_price*quantity as
total_price_of_each_item from Item
--------cashier----------
insert into cashier
values('cash001','mekedes','medihin','12/04/1970',23,'f','+251911114521',
'[email protected]')
------give_service-----
insert into givem_service values('cu001','emp001')
insert into givem_service values('cu002','emp001')
insert into givem_service values('cu004','emp002')
insert into givem_service values('cu002','emp001')
insert into givem_service values('cu001','emp002')
------sells-----
insert into sells values('emp001','it001',4,(select GETDATE()))
insert into sells values('emp002','it002',3,(select GETDATE()))
insert into sells values('emp001','it001',3,(select GETDATE()))
18
select *from sells
------buys-----
insert into buys values('cu001','it001',6,(select GETDATE()))
insert into buys values('cu001','it002',6,(select GETDATE()))
insert into buys values('cu001','it003',1,(select GETDATE()))
insert into buys values('cu002','it001',5,(select GETDATE()))
insert into buys values('cu002','it002',3,(select GETDATE()))
select*from buys
------managed-----
insert into managed values('man002','emp001','cash001','200',4)
------supply-----
insert into supply values('it002','sup001','12/12/2006')
insert into supply values('it002','sup001','12/12/2006')
------request-----
insert into request values('man002','sup002')
------register-----
insert into rigister values('cash001','it003')
insert into rigister values('cash001','it002')
insert into rigister values('cash001','it003')
insert into rigister values('cash001','it004')
----------------------give_service-----------------------------
select *from givem_service
----------------------buys-----------------------------
select *from buys
----------------------sells-----------------------------
select *from sells
----------------------managed-----------------------------
select *from managed
----------------------supply-----------------------------
select *from supply
----------------------rigister-----------------------------
select *from rigister
----------------------request-----------------------------
select *from request
----------------------give_bill-----------------------------
select *from givel_bill
19
select *from Item
select Item_name,Cost_price,selldate,squantity from Item,sells s,employee
where Item_code=SItem_code and emp_id=Semp_id
select fname,count(Item_code)as total_item from Item,custumer,buys where
Item_code=bitem_code and cust_id=bcust_id and item_type='food'group by
fname
select fname,item_name from item,custumer,buys where Item_code=bitem_code
and cust_id=bcust_id and Item_type='food'
-------------------------employee with
manager----------------------------
select count(Item_code)as sold_item from Item,buys ,custumer where
Item_code=bitem_code and cust_id=bcust_id
select SUM(cost_price*bquantity)as total_income from Item,buys ,custumer
where Item_code=bitem_code and cust_id=bcust_id
-----------------------------------ageregate
function-----------------------
select count(cust_id)as total_number_of_custumer from custumer,buys where
bcust_id=cust_id
SELECT COUNT(emp_id)as employee_no FROM employee
select COUNT(Item_code)from Item where Sattus='solid'
select COUNT(Item_code)from Item where Sattus='liquid'
select COUNT(Item_code)from Item where Sattus='gas'
select SUM(quantity)from Item
select AVG(cost_price)from Item
select fname,COUNT(item_code)from item,custumer,buys where
Item_code=bitem_code and Cust_id=bcust_id group by Fname
select cust_id,fname,lname,item_code,sell_price,quantity from
custumer,item,buys where Item_code=bitem_code and Cust_id=bcust_id
select*,(cost_price*quantity)as totalcost,(sell_price*quantity)as
totalsell ,(cost_price*quantity)-(sell_price*quantity)as profit from
Item
select sum((cost_price*quantity)-(sell_price*quantity))as total_profit
from Item
select COUNT(cust_id)as total_customer_no from custumer
select COUNT(*)as number_of_item from Item
select sum(cost_price*quantity) total_cost,sum(sell_price*quantity)as
total_sell,sum(cost_price*quantity)-sum(sell_price*quantity)as total_cash
from Item
select bdate,fname,Item_name,Cost_price,bquantity,
(Cost_price*bquantity)as total,(Cost_price*bquantity*0.1)as vat,
(Cost_price*bquantity)+(Cost_price*bquantity*0.1)as total_cost from
custumer,Item,buys where Item_code=bitem_code and Cust_id=bcust_id
----------------------------------update
customer---------------------------------
update custumer set Age=year((select getdate()))-year(dob)
update custumer set Fname='bekalu'where Cust_id='cu004'
update custumer set Phone_no='0935012369'where Cust_id='cu002'
20
----------------------------------update
employee---------------------------------
update employee set Age=year((select getdate()))-year(dob)
update employee set Fname='bekalu'where Emp_id='emp001'
update employee set Phone_no='09113526894'where emp_id='emp002'
select*from employee
----------------------------------update
manager---------------------------------
update manager set Age=year((select getdate()))-year(dob)
update manager set Fname='mesfin'where Man_id='man002'
update manager set Phone_no='0911121513'where man_id='man002'
update manager set Email='[email protected]'where man_id='man002'
select*from manager
----------------------------------update
cashier---------------------------------
update cashier set Age=year((select getdate()))-year(dob)
update cashier set Fname='kidist'where cash_id='cash001'
update cashier set Phone_no='0965845695'where cash_id='cash001'
select*from cashier
----------------------------------update
item---------------------------------
update Item set Item_name='mastica'where Item_name='gum'
update Item set shelf_no=3 where Item_code='it002'
update Item set cost_price=sell_price+5 where Cost_price<Sell_price
select*from Item
----------------------------------update
suplier---------------------------------
update suplier set Fname='ermias'where sup_id='sup001'
update suplier set Age=year((select getdate()))-year(dob)
update suplier set city ='bahirdar'where city='adis abebe'
update suplier set Phone_no='0911111135'where sup_id='sup002'
select*from suplier
-------------------------------
delete-------------------------------------------------------
-------------------delete item---------------------------
select *from Item
delete from Item where Exp_date<(select GETDATE())
delete from item where Quantity=0
------------------delete customer------------------------
delete from custumer where age<=21
select*from custumer
------------------delete employee-----------------
delete from employee where Emp_id='emp002'
select *from employee
21
22