Distributed Database Using Linked Server
Distributed Database Using Linked Server
DISTRIBUTED DATABASE
AIM:
To develop and write SQL queries for a distributed database of BookStore at two sites B1 and B2. The
Bookstores are divided into two sites by their ZIP codes.
Description:
A distributed database is a database in which storage devices are not all attached to a common
processing unit such as the CPU, controlled by a distributed database management system. (together
sometimes called a distributed database system). It may be stored in multiple computers, located in the
same physical location; or may be dispersed over a network of interconnected computers. Unlike
parallel systems, in which the processors are tightly coupled and constitute a single database system, a
distributed database system consists of loosely-coupled sites that share no physical components.
There are two principal approaches to store a relation r in a distributed database system:
A) Replication B) Fragmentation/Partitioning
A) Replication: In replication, the system maintains several identical replicas of the same relation r in
different sites.
Data is more available in this scheme. Parallelism is increased when read request is served.
Increases overhead on update operations as each site containing the replica needed to be updated in
order to maintain consistency.
B) Fragmentation: The relation r is fragmented into several relations r1, r2, r3....rn in such a way that
the actual relation could be reconstructed from the fragments and then the fragments are scattered to
different locations. There are basically two schemes of fragmentation:
Horizontal fragmentation - splits the relation by assigning each tuple of r to one or more fragments.
Vertical fragmentation - splits the relation by decomposing the schema R of relation r.
Linked servers provide SQL Server the ability to access data from remote data sources. Using these
mechanisms, we can issue queries, perform data modifications and execute remote procedures.
Database Design:
1. Create horizontal partitioning table Books (Bookid, bookname, totalqty, price, topic) in 2
Bookstore Databases based on two zip codes and name it as B1 and B2 Databases
2. B1 in One server(Server Name :PGLAB22) and B2 in another server (Server Name :PGLAB22\
SQLEXPRESS)
Phase 1:
Phase 2:
Password : SDNB
11. Select user mapping and choose the database b2 and give the user name : user1
12. Then Click ok.
13. Go to database B2 and select security -> users-> user1
14. Rightclick user1 and click securables.
15. In securables click search -> select all objects and give ok.
16. Click Object types and select databases and ok
17. Browse the database B2 and select the permissions like select, update..
Phase 3 :
use B1;
select * from [PGLAB22\SQLEXPRESS].B2.dbo.books
union
select * from [PGLAB22].B1.dbo.books;