0% found this document useful (0 votes)
120 views7 pages

K Scheme DMS PR1-13

Uploaded by

bobateaditya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views7 pages

K Scheme DMS PR1-13

Uploaded by

bobateaditya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

PR-1

Steps for DBMS Software installation


1) Open google chrome and navigate to oracle database 21c XE download
2) Download Oracle database 21c XE for windows 10 Pro 64 bit
3) Extract the Zip file and click on setup.exe
4) Follow the Installation procedure and provide the
Username: SYSTEM
Password: Admin
5) After login run the SQL Commands.

PR-2
X.
3. Draw E-R diagram for Library Management system.

4. EMP (empno, ename, mgr, job, deptno, loc, dname)


To normalize the given relation EMP up to 3NF (Third Normal Form), we need to
break it down into smaller relations to eliminate data redundancy and dependency.
Original Relation:
EMP (empno, ename, mgr, job, deptno, loc, dname)
First Normal Form (1NF):
The relation is already in 1NF since each attribute has atomic values.
Second Normal Form (2NF):
To achieve 2NF, we need to ensure that each non-key attribute depends on the entire primary
key.
Primary Key: empno
Non-Key Attributes:
- ename depends on empno (okay)
- mgr depends on empno (okay)
- job depends on empno (okay)
- deptno depends on empno (not entirely, it depends on deptno itself)
- loc depends on deptno (not empno)
- dname depends on deptno (not empno)

Decomposition:
Create two relations:
EMP1 (empno, ename, mgr, job)
DEPT (deptno, loc, dname)
Modified Relations:
EMP1 (empno, ename, mgr, job, deptno)
DEPT (deptno, loc, dname)
Third Normal Form (3NF):
To achieve 3NF, we need to ensure that if a non-key attribute depends on another non-key
attribute, then it should be moved to a separate relation.
In EMP1, deptno depends on empno, but deptno is a determinant for loc and dname in DEPT.
So, we're good.
However, mgr in EMP1 might depend on empno of the manager, not the current employee.
To resolve this, create another relation:
EMP_MGR (empno, mgr_empno)
Final Relations:
EMP (empno, ename, job, deptno)
EMP_MGR (empno, mgr_empno)
DEPT (deptno, loc, dname)
XI
1. Create database BCPC
2. Create table EMP(empno number(4),ename varchar2(10), job varchar2(9),mgr
number(4),hiredate date,sal number(7,2),comm number(7,2),deptno number(2));
3. Alter table emp add constraint pk primary key (ID);
4. Create table dept(deptno number(2),dname varchar2(10),loc varchar2(20));
PR-3
XI
1. Create table Employee (Emp_no int primary key,E_name varchar2(10),Dept_no
int,Dept_name varchar2(10),Job_Id int,Salary number);
2. Create table emp03(empn int primary key, empname varchar2(10),Salary
number,phoneno number(10))
Create table Dept03(deptno int primary key, empno int references emp1 on delete
cascade, deptname varchar2(10), location varchar2(10));

XII
1. Create table stud(Rollno int primary key, studname varchar2(10), Percentage float
constraint ckper check(Percentage <100));
2. Alter table stud add City varchar2(10);
3. Alter table stud modify studname varchar2(20);
4. Table created

Passenger_name Train_details Travelling_Date Birthdate

5.
Rollno Studname Percentage Phoneno

PR-4
XI
1. Create table EMP04(EMPNO number, ENAME varchar2(10), DNAME varchar2(10),
JOB varchar2(10),HIREDATE date, LOC varchar2());
Insert into EMP04 values (7876,’ADAMS’,’RESEARCH’,’CLEARK’,’23-May-
1987’,’DALLAS’);
Insert into EMP04 values (7499,’ALLEN’,’SALES’,’SALESMAN’,’20-FEB-
1981’,’CHICAGO’);
Insert into EMP04 values (7698,’SMITH’,’SALES’,’MANAGER’,’01-May-
1981’,’CHOCAGO’);
Insert into EMP04 values (7782,’CLARK’,’ACCOUNTING’,’MANAGER’,’09-
JUN-1981’,’NEW YORK’);

2. Insert all
Insert into EMP04 values (7902,’FORD’,’RESEARCH’,’ANALYST’,’03-DEC-
1981’,’DALLAS’)
Insert into EMP04 values (7900,’JAMES’,’SALES’,’ CLEARK’, ’03-DEC-
1981’,’CHICAGO’)
Insert into EMP04 values (7566,’JONES’,’ RESEARCH’,’MANAGER’,’02-APR-
1981’,’ DALLAS’)
Insert into EMP04 values (7839,’KING’,’ACCOUNTING’,’PRESIDENT’,’17-NOV-
1981’,’NEW YORK’)
Select * from dual;
3. Delete from EMP04 where ENAME=’SMITH’;
4. UPDATE EMP04 set JOB=’MANAGER’ where ENAME=’ADAMS”;
5. Select EMPNO,LOC from EMP04;

PR-05
XI
2. Create table EMP05 (empno int, empname varchar2(10), salary number , phno
number(10));
Create table Dept05 (deptno int, empno number, deptname varchar2 (10), location
varchar2 (109), jobtype varchar2 (10));

•Create user Jay identifies by any admin;


SQL> create user Jay identified by admin;
• Grant create table, create view to Jay;
SQL> grant create table, create view to jay;
• Grant select, insert, update on Emp to Jay;
SQL>Grant select, insert, update on EMP05 to jay;
• Grant select, update (deptno, empno) on Dept to Jay;
SQL>Grant select, insert, update (deptno, empno) on SYSTEM.dept to jay;
• Alter user Jay identified by admin;
SQL>alter user Jay identified by admin;
• Revoke create table, create views from Jay;
SQL> revoke create table, create view from jay;
• Revoke select, insert, update on EMP05 from Jay;
SQL>revoke select, insert, update on SYSTEM.EMP05 from Jay;
• Create role emp_pvr;
SQL>create role EMP_PVR;
• Grant create table, create views to emp_pvr;
SQL> Grant Create table, create view to EMP_PVR;
• Grant emp_pvr to Jay, John;
SQL>Grant EMP_PVR to Jay, John;

XII
1. Create the user Jay and implement the following commands on table EMP and Dept.
SQL> create user Jay identified by admin;
2. Write a query to grant select, insert, delete privileges on EMP and Dept table.
SQL> Grant select any table, insert any table, delete any table to jay;
3. Write a query to grant update privilege on columns of empno and salary on EMP table.
SQL> Grant update (empno, Salary) on SYSTEM.EMP05 to jay;
4. Write a query to revoke all above privileges from EMP and Dept table.
SQL> Revoke select any table, insert any table, delete any table from Jay;
5. Write a query to create role dept_pvr.
SQL>create role Dept_PVR;
6. Write a query to assign system privileges- create table, create view to role dept_pvr;
SQL>grant create table, create vies to Dept_PVR;
7. Write a query to assign above system privileges to users Jay and John.
SQL>grant Dept_PVR to Jay, John;
8. Write a query to assign object privileges- select, insert, delete to role dept_pvr.
SQL>grant select, insert, delete to Dept_PVR;
9. Write a query to assign above object privileges to users’ jay and john.
SQL>grant Dept_PVR to Jay, John;

PR-06
XI
Create table EMP06 (ID number, Name Varchar2 (10), salary number);
Insert into EMP06 values (1,’Kapil’, 10000);
Insert into EMP06 values (2,’Rahul’, 12000);
Insert into EMP06 values (3,’Om’, 15000);

1. Write TCL command to save all the changes made so far in the EMP
SQL> Commit;
2. Delete any one record in the EMP table created earlier and undo the deletion operation
SQL > Savepoint S1;
SQL> Delete from EMP06 where Id=3;
SQL> Rollback to S1;
3. You are in the middle of a transaction and want to set a save point named
BeforeSalaryUpdate. Write the SQL command to set this save point.
SQL>savepoint BeforeSalaryUpdate;
SQL> update EMP06 set Salary=Salay+500
PR-07
XI
1. Create table Orders(Cust_ID number,Order_Id number ,Items varchar2(10),Amount
number);
i) Select Amount+200 as Total_amount from Orders;
ii) Select Amount-200 as Offer_Price from Orders;
iii) Select Amount*5 as Revised_Amount from Orders;
iv) Select Amount/2 as Half_Amount from Orders;
v)
PR-08
XI
1. Create table EMP(empno number(4),ename varchar2(10), job varchar2(9),mgr
number(4),hiredate date,sal number(7,2),comm number(7,2),deptno number(2));

i) Select * from EMP8 where City=’Mumbai’ and Sal >50000;


ii) Select * from EMP8 where Job=’Clerk’ or Comm =50000;
iii) Select * from EMP8 where Sal>=20000 and Sal <= 50000;
Select * from EMP8 where sal between 20000 and 50000;
iv) Select * from EMP8 where City In (‘Mumbai’,’Pune’,’Nashik’,’Nagpur’);

PR-09
XI
1. Create table student(Roll_No int, Stu_name varchar2(10), Course_Id number, Per
float);

i) Select Stu_Name, Course_Id from student where per >=60 and per <=100 ;
ii) Select * from student where Roll_No >15 ;
iii) Select Stu_Name, Roll_No from student where Course_Id !=121 ;

PR-10
XI
1. Create table EMP101 (empnonumber ,ename varchar2(10), deptno number);
Create table EMP102 (empnonumber, ename varchar2 (10), deptno number);
i) Select * from emp101 union all select * from emp2;
ii) Select * from emp101 union select * from emp2;
iii) Select * from emp101 intersect select * from emp2;
iv) Select * from emp101 minus select * from emp2;

You might also like