Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts

DAY 5 : DISTRIBUTED DBMS



What is Distributed Database Management System ?

A distributed database management system is a software system that permits the management of the distributed database and makes the distribution transparent to the users. A distributed database is a collection of multiple, logically interrelated databases distributed over a computer network. Sometimes distributed database system is used to refer jointly to the distributed database and the distributed DBMS.
Distributed database management systems can be architected as client-server systems or peer-to-peer ones. In the former, one or more servers manage the database and handle user queries that are passed on by the clients. The clients usually have limited database functionality and normally pass the SQL queries over to the servers for processing. In peer-to-peer systems, each site has equal functionality for processing.

A distributed database is a database that is under the control of a central database management system (DBMS) in which storage devices are not all attached to a common CPU. It may be stored in multiple computers located in the same physical location, or may be dispersed over a network of interconnected computers.
Collections of data (eg. in a database) can be distributed across multiple physical locations. A distributed database is distributed into separate partitions/fragments. Each partition/fragment of a distributed database may be replicated (ie. redundant fail-overs, RAID like).
Besides distributed database replication and fragmentation, there are many other distributed database design technologies. For example, local autonomy, synchronous and asynchronous distributed database technologies. These technologies' implementation can and does definitely depend on the needs of the business and the sensitivity/confidentiality of the data to be stored in the database. And hence the price the business is willing to spend on ensuring data security, consistency and integrity.

Basic architecture

A database server is the software managing a database, and a client is an application that requests information from a server. Each computer in a system is a node. A node in a distributed database system act as a client, a server, or both, depending on the situation.
Horizontal fragments
subsets of tuples (rows) from a relation (table).
Vertical fragments
subsets of attributes (columns) from a relation (table).
Mixed fragment
a fragment which is both horizontally and vertically fragmented.
Homogeneous distributed database
uses one DBMS (eg: Oracle).
Heterogeneous distributed database
uses multiple DBMS's (eg: Oracle and MS-SQL and PostgreSQL).
Users access the distributed database through:
Local applications
applications which do not require data from other sites.
Global applications
applications which do require data from other sites.

 

Important considerations

Care with a distributed database must be taken to ensure that:
  • The distribution is transparent — users must be able to interact with the system as if it was one logical system. This applies to the systems performance, and methods of access amongst other things.
  • Transactions are transparent — each transaction must maintain database integrity across multiple databases. Transactions must also be divided into subtransactions, each subtransaction affecting one database system.

Advantages of distributed databases

  • Reflects organizational structure — database fragments are located in the departments they relate to.
  • Local autonomy — a department can control the data about them (as they are the ones familiar with it.)
  • Improved availability — a fault in one database system will only affect one fragment, instead of the entire database.
  • Improved performance — data is located near the site of greatest demand, and the database systems themselves are parallelized, allowing load on the databases to be balanced among servers. (A high load on one module of the database won't affect other modules of the database in a distributed database.)
  • Economics — it costs less to create a network of smaller computers with the power of a single large computer.
  • Modularity — systems can be modified, added and removed from the distributed database without affecting other modules (systems).

Disadvantages of distributed databases

  • Complexity — extra work must be done by the DBAs to ensure that the distributed nature of the system is transparent. Extra work must also be done to maintain multiple disparate systems, instead of one big one. Extra database design work must also be done to account for the disconnected nature of the database — for example, joins become prohibitively expensive when performed across multiple systems.
  • Economics — increased complexity and a more extensive infrastructure means extra labour costs.
  • Security — remote database fragments must be secured, and they are not centralized so the remote sites must be secured as well. The infrastructure must also be secured (eg: by encrypting the network links between remote sites).
  • Difficult to maintain integrity — in a distributed database enforcing integrity over a network may require too much networking resources to be feasible.
  • Inexperience — distributed databases are difficult to work with, and as a young field there is not much readily available experience on proper practice.

DAY-1: EXAMPLE-1


Student Table

Key word: Select, Create, Insert
Schema:

Entity/Field Name
Data Type
Student_id
Number(10)
Name
Varchar2(30)
Program_id
Varchar2(15)
City
Varchar2(15)
Division
Varchar2(15)
Country
Varchar2(15)

DDL for Create Above Table:

SQL>create table student
(student_id number(10),
name varchar2(30),   
program_id varchar2(15),
city varchar2(15),
division varchar2(15),
country varchar2(15)
);

After created the student table, naturally we may try to insert some values or data. It’s a natural sense to keep data in database for further use. To see the inserted data, the SELECT command is only one way according to the SQL statement writing rule.

Insert Value for Above Table:

SQL> insert into student
    values(200819222,'Adina Bashar','English','Noakhali','Chittgong','Bangladesh');

Using the above command Insert some values as you like. After that or after some moments you may see your data. Use the below statement to see your inserted data or value/records. There are lots of styles of inserting values to the table. Visit HERE to get more ideas of insert command.


View or See Value from Above Table:

SQL> select * from student;
The above statement will return all records with all field from student table.

SQL> select student_id,name from student;
The above SQL command will return only student_id and name of all students.

SQL> select name, city from student where student_id=200819222;
The above SQL command will return only name and city of a student whose id is 200819222.

Click HERE to view more example of SELECT command


In Day-1, our target is to understand the SQL, not to know create, insert or any other SQL command. We will discuss for those with details. The day is only to understand the SQL and the three clauses of SQL statement. They are SELECT, FROM and WHERE and also their implementation.

Some Things You Must Know about Database Management related to SQL. <<CLICK HERE>>

DAY-1: THE SQL

What is SQL?

SQL stands for Structured Query Language. SQL is used to communicate with a database. According to American National Standards Institute, it is the standard language for relational database management systems.

SQL statements are used to perform tasks such as update data on a database, or retrieve data from a database. Some common relational database management systems that use SQL are: Oracle, Sybase, Microsoft SQL Server, Access, etc. 

However, the standard SQL commands can be used to accomplish almost everything that one needs to do with a database. This tutorial will provide you with the instruction on the basics of each of these commands as well as allow you to put them to practice using the SQL Interpreter.

SQL expression consists of three clauses: select, from, and where. A sample SQL statement that makes this query is:

SELECT * FROM STUDENT 

The most commonly used statement in SQL is the SELECT statement, which retrieves data from the database and returns the data to the user. The STUDENT table example illustrates a typical example of a SELECT statement situation. In addition to the SELECT statement, SQL provides statements for creating new databases, tables, fields, and indexes, as well as statements for inserting and deleting records. The  from clause by itself defines a Cartesian Product of the relations in the clause. Here STUDENT is the name of the relation (Entity Set/Table).

Now, Analyze the STUDENT table and SELECT statement with fundamental knowledge of Database, Table, Field from HERE.

Popular Posts