Professional Documents
Culture Documents
Computer Application
Computer Application
BBA IIB
BUS-19F-044
Computer Application
Assignment 02
Contents
Considered Scenario:...................................................................................................................................2
1.Selection of Database...............................................................................................................................2
2. Identifying the requirements for the database based on the purpose for the database and the data to
fill the database...........................................................................................................................................2
3.Create a database design based on the requirements for the database, create the physical database,
and load data into the database..................................................................................................................3
Create Database:.....................................................................................................................................3
Create Tables:..........................................................................................................................................3
Employee.............................................................................................................................................3
User.....................................................................................................................................................3
admin...................................................................................................................................................3
Customer.............................................................................................................................................5
Product................................................................................................................................................5
Supplier...............................................................................................................................................5
Order Detail.........................................................................................................................................5
Delivery................................................................................................................................................5
Store Record........................................................................................................................................5
Inserting Data:.........................................................................................................................................6
Admin..................................................................................................................................................6
Employee.............................................................................................................................................6
User.....................................................................................................................................................6
Product................................................................................................................................................7
Supplier...............................................................................................................................................7
4.After loading the database, carry out sample queries that would be performed on the actual database.
Show the results of the sample queries......................................................................................................7
Sample Queries:......................................................................................................................................7
Customer.............................................................................................................................................7
Order Detail.........................................................................................................................................7
Delivery................................................................................................................................................8
View Update Delete Insert Search Employee..........................................................................................8
View Update Delete Insert Search User...................................................................................................9
View Update Delete Insert Search Admins............................................................................................10
View Update Delete Insert Search Increment and Decrement Products...............................................10
View Update Delete Insert Search Supplier...........................................................................................12
View Update Delete Insert Search Delivery...........................................................................................12
View Update Delete Insert Search Order Details...................................................................................13
Considered Scenario:
Suppose, Customer will come in the market choose the stuff they want to
buy. Then come to Counter where employee of the market serving the customer
at counter will add the record of for goods which customer wanted to buy. Then
employee will generate the slip. And will ask the customer for the payment
method.
After the customer has paid the bill. He /She will be able to use the facility of
Home Delivery by Filling the form.
1.Selection of Database
Selecting SQL Server Management Studio for this database as it is
o Cost- free
o Easy to install
o Fast and efficient
o Admin Details
o User Details
o Employee Details
o Items in list of goods with price and quantity.
o Customer Details
o Store Order Details
o Delivery System
Create Database:
Using SQL Server Management Studio 18
create Database Store;
use Store;
Create Tables:
Employee
create table tbl_employee
(
e_id int not null,
primary key (e_id),
emp_name varchar(50) not null,
gender varchar(6) not null,
age int not null,
email varchar (49) not null,
address varchar(250) not null,
ph_no varchar(30) not null,
);
User
create table tbl_user
(
u_id int not null,
primary key (u_id),
name varchar (75) not null,
pass varchar(30) not null,
ph_no varchar(15) not null,
email varchar(49) not null,
address varchar(250) not null,
date_of_birth Date not null,
);
admin
create table tbl_admin
(
a_id int not null,
primary key (a_id),
name varchar (75) not null,
pass varchar(30) not null,
ph_no varchar(15) not null,
email varchar(49) not null,
address varchar(250) not null,
date_of_birth Date not null,
);
Customer
create table tbl_customer
(
c_id int not null,
primary key (c_id),
d_c Date not null,
time_customer Time not null,
);
Product
create table tbl_product
(
p_id int not null,
primary key (p_id),
name varchar(50) not null,
price int not null,
quantity int not null,
category varchar (17),
);
Supplier
create table tbl_supplier
(
s_id int not null,
primary key (s_id),
company_name varchar(49) not null,
address varchar(250) not null,
p_id int not null,
Foreign Key (p_id) references tbl_product(p_id),
);
Order Detail
create table tbl_order_detail
(
o_id int not null,
primary key (o_id),
c_id int not null,
Foreign Key (c_id) references tbl_customer(c_id),
p_id int not null,
Foreign Key (p_id) references tbl_product(p_id),
);
Delivery
create table tbl_delivery
(
order_id int not null,
c_id int not null,
Foreign Key (order_id) references tbl_order_detail(o_id),
d_id int not null,
primary key (d_id),
driver_name varchar(55) not null,
driver_no int not null,
);
Store Record
create table tbl_store_record
(
sr_id int not null,
primary key (sr_id),
selling int not null,
purchasing int not null,
order_id int not null,
Foreign Key (order_id) references tbl_order_detail(o_id),
supplier_id int not null,
Foreign Key (supplier_id) references tbl_supplier(s_id),
)
Inserting Data:
Admin
insert into tbl_admin values ('1','Mohsin','mohsin','mohsin123','mohsin@mail.com','House
# 96 Street # 07 Sector # 04 Naval Colony Hub River Road Karachi','1997-11-29')
insert into tbl_admin values ('2','Ahmed','ahmed','ahmed123','ahmed@mail.com','House # 17
Street # 09 Sector # 03 Naval Colony Hub River Road Karachi','1996-08-12')
insert into tbl_admin values ('3','Ali','ali','ali123','ali@mail.com','House # 06 Street
# 02 Sector # 02 Naval Colony Hub River Road Karachi','1993-01-23')
insert into tbl_admin values ('4','Baber','baber','babaer123','baber@mail.com','House #
17 Street # 12 Sector # 01 Naval Colony Hub River Road Karachi','1992-06-13')
insert into tbl_admin values ('5','Saqib','saqib','saqib123','saqib@mail.com','House # 03
Street # SR Sector # 04 Naval Colony Hub River Road Karachi','1998-05-18')
Employee
insert into tbl_employee values ('1','Abeera','Female',31,'abeera@mail.com','Appartment 3
Block A Karachi','+923992547')
insert into tbl_employee values ('2','Altaf','Male',25,'altaf@mail.com','Appartment 1
Block C Lahore','+9239925212')
insert into tbl_employee values ('3','Fatima','Female',18,'fatima@mail.com','Appartment
33 Block F Karachi','+923112333')
insert into tbl_employee values ('4','Shams','Male',21,'shams@mail.com','Appartment 12
Block H Karachi','+9239922343')
Select * from tbl_employee
User
insert into tbl_user values ('1','anas','anas123','+927111254','anas@mail.com','H 12 St 9
Naval Karachi','1991-10-10')
insert into tbl_user values
('2','ammar','ammar123','+928112548','ammar@mail.com','Appartment 3 Block B
Karachi','1993-10-31')
insert into tbl_user values ('3','noman','noman123','+924855512','noman@mail.com','Sec 9
St 3 H 1 Karachi','1889-03-28')
select * from tbl_user
Product
insert into tbl_product values ('1','Bloody HeadPhone 4','4000','5','Gaming')
insert into tbl_product values ('3','Cricket Bat Large','1000','50','Sports Goods')
insert into tbl_product values ('2','Need For Speed Collection','50','100','Gaming')
select * from tbl_product
Supplier
insert into tbl_product values ('1','Bloody HeadPhone 4','4000','5','Gaming')
insert into tbl_product values ('3','Cricket Bat Large','1000','50','Sports Goods')
insert into tbl_product values ('2','Need For Speed Collection','50','100','Gaming')
select * from tbl_product
4.After loading the database, carry out sample queries that would be
performed on the actual database. Show the results of the sample
queries.
Sample Queries:
Customer
insert into tbl_customer values ('1','2020-Aug-05','13:10')
Delivery
insert into tbl_delivery values ('1','1','1','Ishtiaq','5')
select * from tbl_delivery
-----------------Show Employees
create procedure pro_show_employees
AS
Select * from employees
Go
--
exec pro_show_employees
----------------Delete Employees
----------------Insert Employees
----------------Search Emloyees
----------------Delete Users
----------------Insert Users
----------------update Users
----------------Search Users
create proc pro_search_users
@Name varchar(50)
As
Select * from users where Name Like '%'+@Name+'%'
Go
exec pro_search_users 'Write Name Here To Search'
-----------------Show admin
----------------Delete Admin
----------------Insert Admin
----------------update Admin
-----------------Show Products
create procedure pro_show_products
AS
Select * from products
Go
--
exec pro_show_products
----------------Delete Products
----------------Insert Products
----------------Search Products
-----------------Show Suppliers
create procedure pro_show_suppliers
AS
Select * from suppliers
Go
--
exec pro_show_suppliers
----------------Delete Suppliers
----------------Insert Suppliers
----------------Search Suppliers
-----------------Show Delivery
create procedure pro_show_delivery
AS
Select * from delivery
Go
--
exec pro_show_delivery
----------------Delete Delivery
----------------Insert Delivery
----------------Search delivery
-----------------Show Orders
create procedure pro_show_orders
AS
Select * from orders
Go
--
exec pro_show_orders
----------------Delete Orders
----------------Insert Orders
----------------Search Orders