0% found this document useful (0 votes)
20 views3 pages

Lab Fragmentation

The document discusses different techniques for fragmenting and distributing data across multiple databases. It describes horizontal fragmentation where the EMP table is fragmented into three separate tables based on the city column. Vertical fragmentation is shown where the EMP table is split into two tables, one containing the salary columns and one containing the remaining columns. Finally, hybrid fragmentation is demonstrated fragmenting the EMP table both horizontally on the city column and vertically on selected non-salary columns.

Uploaded by

abdul moiz
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)
20 views3 pages

Lab Fragmentation

The document discusses different techniques for fragmenting and distributing data across multiple databases. It describes horizontal fragmentation where the EMP table is fragmented into three separate tables based on the city column. Vertical fragmentation is shown where the EMP table is split into two tables, one containing the salary columns and one containing the remaining columns. Finally, hybrid fragmentation is demonstrated fragmenting the EMP table both horizontally on the city column and vertically on selected non-salary columns.

Uploaded by

abdul moiz
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/ 3

Lab: Fragmentation

Create table fragmntedTableName as


Select columnNames_with_KeyColumn
From tableName;

Non- Distributed Data

Non-Fragmented,

Distributed Data Design Techniques

Replicated, Partially replicated, Non-Replicated,


Fragmented (Vertical, Horizontal, Hybrid), Non-Fragmented,
Mixed distribution

Horizontal Framework: Primary horizontal fragmentation (PHF) and Derived Horizontal fragmentation (DHF).

Horizontal Fragmentation
Primary
Select *
into EMP_KHI
From EMP
Where city=’Karachi’

Select *
into EMP_ISB
From EMP
Where city=’Islamabad’

Select *
into EMP_LHR
From EMP
Where city=’Lahore’

Derived
Create table PROJ1_EmpKhi as
Select PNo, PName, Budget, PROJ.Dno
From PROJ, EMP_KHI
Where PROJ.Dno = EMP_KHI.Dno;
Vertical Fragmentation

Create table EMP_SAL as


Select EmpID, SAL
From EMP;

Create table EMP_NON_SAL as


Select EmpID, Name, Loc, DoB, Dept
From EMP;

Hybrid Fragmentation
Create table NON_SAL_KHI_EMP as
Select EmpID, Name, DOB, Dept
From EMP
Where City = ‘Karachi;

Create table NON_SAL_LHR_EMP as


Select EmpID, Name, DOB, Dept
From EMP
Where City = ‘Lahore’;
Create table NON_SAL_ISB_EMP as
Select EmpID, Name, DOB, Dept
From EMP
Where City = ‘Islamabad’;

Checking Fragmentation Is Correct


Horizontal Fragmentation
Select * From EMP_KHI
union
Select * From EMP_ISB
Where City=’Islamabad’

Vertical Fragmentation

Select * From EMP_SAL;


Left join
Select * From EMP_NON_SAL;

CREATE VIEW view_name AS


SELECT column1, column2, ...
FROM table_name
WHERE condition;
Select eid, ename, DOB, Dept
into NON_SAL_ISB_EMP
From EMP
Where city = 'Islamabad'

©
DROP VIEW view_name;
DROP table table_name;

Linked Server
SELECT *
into EMP_KHI2
FROM [JIB].[SampleDB].[dbo].[EMP]
where [city] ='Karachi'

You might also like