Академический Документы
Профессиональный Документы
Культура Документы
Part I
Advanced Database Systems
Practical No.: 1
QUESTION:
Create global conceptual schema, ‘Employee (empid, name, addr, desg, salary)’ and insert 10
records. Divide Employee into horizontal fragmented for the condition Salary <= 10000 into
tables ‘Worker(empid, name, addr, desg, salary)’ and Salary > 10000 into tables
‘Officer(empid, name, addr, desg, salary)’ on two different Databases and fire following
queries.
Display all the records Employee.
Display all the records of Employee from table Worker.
Display all the records of Employee from table Officer.
Display salary of all the Employee.
Display name & empid of the employee whose salary > 10000.
Select all records of an employee whose empid is 4.
Select all records of an employee who are officers.
SCENARIO:
We have created the schema Employee for storing the details of Employee. Details are
empid, name, addr, desg, salary. Then we divided the main schema into two tables, Worker &
Officer and store both of them in different databases, using the Horizontal fragmentation
concept. To make the connectivity link is created between both the databases. Between
Worker & Officer link is db1todb2 and between Officer& Worker link is db2todb1. Using
both the links the queries are being fired.
SETUP:
ORACLE 9i
ORACLE 9i db1todb2
db1 db2
db2todb1
What is link?
Link is the virtual connection between two services, which help us to get access to the
table present into other service when we are in one service.
Syntactical format for creating the link is as follows:
SQL> create public database link <link name> connect to <user name>identified by
<password> using <’Service name’>;
1. db1 to db2
SQL> create public database link db1todb2 connect to scott identified by tiger using
'upgdb2';
Database link created.
2. db2 to db1
SQL> create public database link db2todb1 connect to scott identified by tiger using
'upgdb1';
Database link created.
1. Employee in db1
SQL> create table employee_zubair(empid int primary key not null, name varchar2(20) not
null,addr varchar(20) not null,desg varchar2(20) not null,salary number not null);
Table created.
2. Worker in db1
SQL> create table worker_zubair(empid int primary key not null, name varchar2(20) not
null,addr varchar(20) not null,desg varchar2(20) not null,salary number not null);
Table created.
3. Officer in db2
SQL> create table officer_zubair(empid int primary key not null, name varchar2(20) not
null,addr varchar(20) not null,desg varchar2(20) not null,salary number not null);
Table created.
Creating Trigger for inserting values automatically into either Worker or Officer table
when a new record is inserted in Employee:
*** Retrieving the records when we are in the database db2 ***
5) Display name & empid of the employee_zubair whose salary > 10000:
*** Retrieving the records of employee when we are in the database db2 ***
*** Retrieving the records when we are in the database db2 ***