Horizontal fragmentation in Distributed Database System
Horizontal fragmentation in Distributed Database System
Partitions a table along
its tuples is performed based on some Predicate/ Condition
Consists of a subset of the tuples of a relation.
Defined using Selection Operation of relational Algebra
spredicate (R)
F1 = scity = ‘Lahore’ (Employee)
F1 = scity = ‘Karachi’ (Employee)
Horizontal Fragmentation Example
CREATE TABLE employee(
emp_no INTEGER PRIMARY KEY,
emp_name CHAR(20) NOT NULL,
City CHAR(20) NOT NULL,
salary int
)
insert into employee values(1,'Asad','Lahore',18000)
insert into
employee values(2,'hafeez','karachi',20000)
insert into
employee values(3,'Wasiq','Lahore',30000)
insert into
employee values(4,'Sohail','Lahore',50000)
insert into
employee values(5,'Atif','Peshawer',45000)
insert into
employee values(6,'Naveed','Multan',55000)
insert into
employee values(7,'Manawar','Karachi',80000)
insert into
employee values(8,'Adnan','Peshawar',70000)
insert into
employee values(9,'Ahir','Multan',45000)
insert into
employee values(10,'Aslam','Peshawer',90000)
insert into
employee values(11,'Abdullah','Multan',55000)
insert into
employee values(12,'Salman','Karachi',80000)
insert into
employee values(13,'Fitama','Peshawar',70000)
insert into
employee values(14,'Shahbaz','Multan',45000)
insert into
employee values(15,'sultan','Peshawer',90000)
Select * From Employee
Create Fragment 1
select * into employee1 from employee where city = 'Multan'
select * from employee1
Create Fragment 2
select * into employee2 from employee where city = 'Lahore'
select * from employee2
Create Fragment 3
select * into employee3 from employee where city = 'Karachi'
select * from employee3
Create Fragment 4
select * into employee4 from employee where city = ‘Peshawer'
select * from employee4
Combine All
Four Fragment
select * from employee1
union all
select * from employee2
union all
select * from employee3
union all
select * from employee4
Post a Comment