DATABASE MANEGEMENT SYSTEM PROJECT
DEPARTMENTAL STORE
DONE BY :
VIGNESH L [20ISR059]
NARENDRA PRASANTH K .P [20ISR030]
MOHANVIKAS R [20ISR027]
Create Table
create table employee(emp_id int,name varchar(40),age int,salary int);
Insert Table
insert into employee values(001,'vicky',25,50000);
insert into employee values(002,'narendra',28,40000);
insert into employee values(003,'mohan',24,30000);
insert into employee values(004,'dinesh',30,25000);
Displaying table
select * from employee;
>>>OUTPUT<<<
emp_id name age salary
1 vicky 25 50000
2 narendra 28 40000
3 mohan 24 30000
4 dinesh 30 25000
CUSTOMER TABLE:
Create table
create table customer(cus_id int,name
varchar(40),age int,city varchar(20));
Insert Table
insert into customervalues(101,'uthra',25,'erode’);
insert into customer values(102,'narendra',39,'erode’);
insert into customer values(103,'pravin',27,'gobi’);
insert into customer values(104,'vignesh',35,'perundurai');
Display Table:
select * from customer;
>>>OUTPUT<<<
cus_id name age city
101 uthra 25 erode
102 narendra 39 erode
103 Pravin 27 gobi
104 vignesh 35 perundurai
Stock Table
Create Table:
create table stock(item_id int,item_name
varchar(40),quantity varchar(20),stock_price float);
Insert Table
insert into stock values(108,'wheat','2kg',200.00);
insert into stock values(109,'powder','3kg',300.00);
insert into stock values(110,'tomoto','2kg',100.00);
insert into stock values(111,'rice','10kg',500.00);
insert into stock values(222,'oil','2lit',500.00);
insert into stock values(333,'sugar','10kg',400.00);
insert into stock values(444,'dhall','2kg',200.00);
insert into stock values(555,'tea_powder','2kg',500.00);
insert into stock values(666,'potato','3kg',100.00);
insert into stock values(777,'brown_sugar','4kg',200.00);
insert into stock values(888,'onion','5kg',200.00);
insert into stock values(999,'red_chilli','2kg',400.00);
Display Table:
select * from stock;
>>>OUTPUT<<<
item_id item_name quantity stock_price
108 wheat 20kg 2000
109 powder 30kg 3000
110 tomoto 20kg 1000
111 rice 100kg 5000
222 oil 20lit 5000
333 sugar 100kg 4000
444 dhall 20kg 2000
555 tea_powder 20kg 5000
666 potato 30kg 1000
777 brown_sugar 40kg 2000
888 onion 50kg 2000
999 red_chilli 20kg 4000
SALES TABLE
Create Table:
create table sales(emp_id int,cus_id int,name
varchar(10),item varchar(10),quantity varchar(10),total_amt
varchar(15));
Insert Table:
insert into sales values(001,101,'uthra','rice','1kg','Rs.50’);
insert into sales values(002,102,'narendra','wheat','2kg','Rs.200’);
insert into sales values(003,103,'pravin','oil','1ltr','Rs.250’);
insert into sales values(004,104,'vignesh','sugar','1.5kg','Rs.60');
display table:
select * from sales;
>>>OUTPUT<<<
emp_id cus_id name item quantity total_amt
1 101 uthra rice 1kg Rs.50
2 102 narendra wheat 2kg Rs.200
3 103 pravin oil 1ltr Rs.250
4 104 vignesh sugar 1.5kg Rs.60
UPDATE TABLE:
update sales set total_amt='100'where cus_id=102;
select * from sales
>>>OUTPUT<<<
emp_id cus_id name item quantity total_amt
1 101 uthra rice 1kg Rs.50
2 102 narendra wheat 2kg Rs.100
3 103 pravin oil 1ltr Rs.250
4 104 vignesh sugar 1.5kg Rs.60
DELETE TABLE :
delete sales where cus_id= 103 ;
select * from sales;
>>>OUTPUT<<<
emp_id cus_id name item quantity total_amt
1 101 uthra rice 1kg Rs.50
2 102 narendra wheat 2kg Rs.100
4 104 vignesh sugar 1.5kg Rs.60
ALTER TABLE :
alter table customer add gender varchar(20);
insert into customer
values(105,'ram',30,'perundurai','male’);
>>>OUTPUT<<<
cus_id name age city gender
101 uthra 25 erode NULL
102 narendra 39 erode NULL
103 pravin 27 gobi NULL
104 vignesh 35 perundurai NULL
105 ram 30 perundurai male
AGGREGATE FUNCTION
MIN :
select min(stock_price) from stock;
>>>OUTPUT<<<
min(stock_price)
100
MAX :
select max(stock_price) from stock;
>>>OUTPUT<<<
max(stock_price)
500
SUM :
select sum(stock_price) from stock;
>>>OUTPUT<<<
sum(stock_price)
3600
AVERAGE:
select avg(stock_price) from stock;
>>>OUTPUT<<<
avg(stock_price)
300
GROUP BY :
select city,count(cus_id) from customer group by city;
>>>OUTPUT<<<
city count(cus_id)
erode 2
gobi 1
Perundurai 2
ORDER BY :
select cus_id,name,age from customer order by age ;
>>>OUTPUT<<<
cus_id name age
101 uthra 25
103 pravin 27
105 ram 30
104 vignesh 35
102 narendra 39
INNER JOIN:
select sales.emp_id,sales.item,sales.quantity,customer.cus_id from sales
inner join customer on sales.cus_id=customer.cus_id;
>>>OUTPUT<<<
emp_id item quantity cus_id
1 rice 1kg 101
2 wheat 2kg 102
3 oil 1ltr 103
4 sugar 1.5kg 104
OUTER JOIN:
select sales.emp_id,employee.name,employee.age from sales left join employee on
sales.emp_id=employee.emp_id order by employee.age;
>>>OUTPUT<<<
emp_id name age
3 mohan 24
1 vicky 25
2 narendra 28
4 dinesh 30
NESTED SUBQUERY:
select * from sales where cus_id IN(select cus_id from customer where
cus_id=103);
>>>OUTPUT<<<
emp_id cus_id name item quantity total_amt
3 103 pravin oil 1ltr Rs.250
VIEW:
create view emp as select emp_id,name,age,salary from employee;
select * from emp;
>>>OUTPUT<<<
emp_id name age salary
1 Vicky 25 50000
2 narendra 28 40000
3 mohan 24 30000
4 dinesh 30 25000
COMMIT AND ROLLBACK:
savepoint x;
savepoint created
create index cover on employee(emp_id,name,age,salary);
update employee set salary=60000 where name='vicky’;
select * from employee;
>>>OUTPUT<<<
emp_id name age salary
1 vicky 25 60000
2 narendra 28 40000
3 mohan 24 30000
4 dinesh 30 25000
Rollback to savepoint x;
Roll back completed
Commit ;
Commit completed
DATABASE MANEGEMENT SYSTEM PROJECT.pptx

DATABASE MANEGEMENT SYSTEM PROJECT.pptx

  • 1.
    DATABASE MANEGEMENT SYSTEMPROJECT DEPARTMENTAL STORE
  • 2.
    DONE BY : VIGNESHL [20ISR059] NARENDRA PRASANTH K .P [20ISR030] MOHANVIKAS R [20ISR027]
  • 3.
    Create Table create tableemployee(emp_id int,name varchar(40),age int,salary int); Insert Table insert into employee values(001,'vicky',25,50000); insert into employee values(002,'narendra',28,40000); insert into employee values(003,'mohan',24,30000); insert into employee values(004,'dinesh',30,25000);
  • 4.
    Displaying table select *from employee; >>>OUTPUT<<< emp_id name age salary 1 vicky 25 50000 2 narendra 28 40000 3 mohan 24 30000 4 dinesh 30 25000
  • 5.
    CUSTOMER TABLE: Create table createtable customer(cus_id int,name varchar(40),age int,city varchar(20)); Insert Table insert into customervalues(101,'uthra',25,'erode’); insert into customer values(102,'narendra',39,'erode’); insert into customer values(103,'pravin',27,'gobi’); insert into customer values(104,'vignesh',35,'perundurai');
  • 6.
    Display Table: select *from customer; >>>OUTPUT<<< cus_id name age city 101 uthra 25 erode 102 narendra 39 erode 103 Pravin 27 gobi 104 vignesh 35 perundurai
  • 7.
    Stock Table Create Table: createtable stock(item_id int,item_name varchar(40),quantity varchar(20),stock_price float); Insert Table insert into stock values(108,'wheat','2kg',200.00); insert into stock values(109,'powder','3kg',300.00); insert into stock values(110,'tomoto','2kg',100.00); insert into stock values(111,'rice','10kg',500.00); insert into stock values(222,'oil','2lit',500.00); insert into stock values(333,'sugar','10kg',400.00); insert into stock values(444,'dhall','2kg',200.00); insert into stock values(555,'tea_powder','2kg',500.00); insert into stock values(666,'potato','3kg',100.00); insert into stock values(777,'brown_sugar','4kg',200.00); insert into stock values(888,'onion','5kg',200.00); insert into stock values(999,'red_chilli','2kg',400.00);
  • 8.
    Display Table: select *from stock; >>>OUTPUT<<< item_id item_name quantity stock_price 108 wheat 20kg 2000 109 powder 30kg 3000 110 tomoto 20kg 1000 111 rice 100kg 5000 222 oil 20lit 5000 333 sugar 100kg 4000 444 dhall 20kg 2000 555 tea_powder 20kg 5000 666 potato 30kg 1000 777 brown_sugar 40kg 2000 888 onion 50kg 2000 999 red_chilli 20kg 4000
  • 9.
    SALES TABLE Create Table: createtable sales(emp_id int,cus_id int,name varchar(10),item varchar(10),quantity varchar(10),total_amt varchar(15)); Insert Table: insert into sales values(001,101,'uthra','rice','1kg','Rs.50’); insert into sales values(002,102,'narendra','wheat','2kg','Rs.200’); insert into sales values(003,103,'pravin','oil','1ltr','Rs.250’); insert into sales values(004,104,'vignesh','sugar','1.5kg','Rs.60');
  • 10.
    display table: select *from sales; >>>OUTPUT<<< emp_id cus_id name item quantity total_amt 1 101 uthra rice 1kg Rs.50 2 102 narendra wheat 2kg Rs.200 3 103 pravin oil 1ltr Rs.250 4 104 vignesh sugar 1.5kg Rs.60
  • 11.
    UPDATE TABLE: update salesset total_amt='100'where cus_id=102; select * from sales >>>OUTPUT<<< emp_id cus_id name item quantity total_amt 1 101 uthra rice 1kg Rs.50 2 102 narendra wheat 2kg Rs.100 3 103 pravin oil 1ltr Rs.250 4 104 vignesh sugar 1.5kg Rs.60
  • 12.
    DELETE TABLE : deletesales where cus_id= 103 ; select * from sales; >>>OUTPUT<<< emp_id cus_id name item quantity total_amt 1 101 uthra rice 1kg Rs.50 2 102 narendra wheat 2kg Rs.100 4 104 vignesh sugar 1.5kg Rs.60
  • 13.
    ALTER TABLE : altertable customer add gender varchar(20); insert into customer values(105,'ram',30,'perundurai','male’); >>>OUTPUT<<< cus_id name age city gender 101 uthra 25 erode NULL 102 narendra 39 erode NULL 103 pravin 27 gobi NULL 104 vignesh 35 perundurai NULL 105 ram 30 perundurai male
  • 14.
    AGGREGATE FUNCTION MIN : selectmin(stock_price) from stock; >>>OUTPUT<<< min(stock_price) 100 MAX : select max(stock_price) from stock; >>>OUTPUT<<< max(stock_price) 500 SUM : select sum(stock_price) from stock; >>>OUTPUT<<< sum(stock_price) 3600
  • 15.
    AVERAGE: select avg(stock_price) fromstock; >>>OUTPUT<<< avg(stock_price) 300 GROUP BY : select city,count(cus_id) from customer group by city; >>>OUTPUT<<< city count(cus_id) erode 2 gobi 1 Perundurai 2
  • 16.
    ORDER BY : selectcus_id,name,age from customer order by age ; >>>OUTPUT<<< cus_id name age 101 uthra 25 103 pravin 27 105 ram 30 104 vignesh 35 102 narendra 39
  • 17.
    INNER JOIN: select sales.emp_id,sales.item,sales.quantity,customer.cus_idfrom sales inner join customer on sales.cus_id=customer.cus_id; >>>OUTPUT<<< emp_id item quantity cus_id 1 rice 1kg 101 2 wheat 2kg 102 3 oil 1ltr 103 4 sugar 1.5kg 104
  • 18.
    OUTER JOIN: select sales.emp_id,employee.name,employee.agefrom sales left join employee on sales.emp_id=employee.emp_id order by employee.age; >>>OUTPUT<<< emp_id name age 3 mohan 24 1 vicky 25 2 narendra 28 4 dinesh 30
  • 19.
    NESTED SUBQUERY: select *from sales where cus_id IN(select cus_id from customer where cus_id=103); >>>OUTPUT<<< emp_id cus_id name item quantity total_amt 3 103 pravin oil 1ltr Rs.250 VIEW: create view emp as select emp_id,name,age,salary from employee; select * from emp; >>>OUTPUT<<< emp_id name age salary 1 Vicky 25 50000 2 narendra 28 40000 3 mohan 24 30000 4 dinesh 30 25000
  • 20.
    COMMIT AND ROLLBACK: savepointx; savepoint created create index cover on employee(emp_id,name,age,salary); update employee set salary=60000 where name='vicky’; select * from employee; >>>OUTPUT<<< emp_id name age salary 1 vicky 25 60000 2 narendra 28 40000 3 mohan 24 30000 4 dinesh 30 25000 Rollback to savepoint x; Roll back completed Commit ; Commit completed