0% found this document useful (0 votes)
1 views

LABE MANUALOF DISTRIBUTED DATABASE SYSTEM

The document provides an overview of distributed database systems, detailing their definition, advantages, challenges, and types, as well as introducing SQL, its components, commands, and operators. It explains key concepts such as data distribution, transaction management, and various types of SQL joins. Additionally, it covers SQL constraints, functions, and security measures, emphasizing the importance of SQL in database management.

Uploaded by

Haseeb Hyder
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

LABE MANUALOF DISTRIBUTED DATABASE SYSTEM

The document provides an overview of distributed database systems, detailing their definition, advantages, challenges, and types, as well as introducing SQL, its components, commands, and operators. It explains key concepts such as data distribution, transaction management, and various types of SQL joins. Additionally, it covers SQL constraints, functions, and security measures, emphasizing the importance of SQL in database management.

Uploaded by

Haseeb Hyder
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

DISTRIBUTED DATABASE SYSTEM

Name:
Naqeeb Hyder

Roll No:
586411

Program:
BSCS 6th

Section:
2020-2024

Punjab Groups Of Colleges Jaranwala Campus


(Affiliated with)

Government College University Faisalabad: GCUF


Introduction Of Distributed Database system

1. Definition:
A distributed database system is a collection of multiple,
interconnected databases distributed over a network, each serving as a
separate logical database.
2. Distribution of Data:
Data is divided and stored across different nodes or sites, often based
on specific criteria such as geographical location, function, or
application.
3. Advantages:
Improved Performance: Distributing data can enhance query
performance by allowing parallel processing.
High Availability: Even if one node fails, the system can continue to
operate with the remaining nodes.
Scalability: Distributing data allows for easier scalability by adding or
removing nodes as needed.
Local Autonomy: Each site can have a degree of autonomy, managing
its data independently.

4. Challenges:
Data Consistency: Ensuring that data remains consistent across
distributed nodes is a significant challenge.
Data Partitioning: Deciding how to partition and distribute data
effectively is a complex task.
Concurrency Control: Managing simultaneous access to the same data
by multiple users requires careful coordination.
Fault Tolerance: Addressing issues related to network failures, node
failures, and ensuring the system remains available.

5. Architecture:
Distributed database systems can have various architectures, including
client-server, peer-to-peer, or a combination of both.

6. Types of Distributed Databases:


Homogeneous Distributed Database: All nodes use the same DBMS.
Heterogeneous Distributed Database: Different nodes may use
different DBMS, and there is a need for data integration.

7. Data Replication:
Copies of data may be maintained at multiple nodes to improve data
availability and reduce latency.

8. Transaction Management:
Ensuring the ACID properties (Atomicity, Consistency, Isolation,
Durability) across distributed transactions is crucial.
9. Global Query Optimization:
Optimizing queries that involve data from multiple distributed nodes is
a complex task, requiring intelligent query planning.
10. Security:
Ensuring the security and integrity of data during transmission and
storage in a distributed environment is a critical concern.

Introduction to SQL

1. Definition of SQL:
SQL, which stands for Structured Query Language, is a domain-specific
language used to manage and manipulate relational databases.
2. Purpose of SQL:
SQL is primarily used for:
Defining and manipulating the structure of a database (Data Definition
Language - DDL).
Performing operations on data stored in the database (Data
Manipulation Language - DML).
Controlling access and permissions to the database.
3. Key Components of SQL:
Data Definition Language (DDL):
Defines and manages the structure of the database, including creating,
altering, and deleting tables and schemas.
Examples: CREATE TABLE, ALTER TABLE, DROP TABLE.
Data Manipulation Language (DML):

Manipulates the data stored in the database, including querying,


inserting, updating, and deleting records.
Examples: SELECT, INSERT, UPDATE, DELETE.
Data Query Language (DQL):

Focused on retrieving data from the database.


Primary command: SELECT.
Data Control Language (DCL):

Manages access and permissions to the database.


Examples: GRANT, REVOKE.
4. Basic SQL Commands:
SELECT:

Used to retrieve data from one or more tables.


Example: SELECT column1, column2 FROM table_name WHERE
condition;
INSERT:
Adds new records to a table.
Example: INSERT INTO table_name (column1, column2) VALUES (value1,
value2);
UPDATE:

Modifies existing records in a table.


Example: UPDATE table_name SET column1 = value1 WHERE condition;
DELETE:

Removes records from a table.


Example: DELETE FROM table_name WHERE condition;
CREATE TABLE:

Creates a new table in the database.


Example: CREATE TABLE table_name (column1 datatype, column2
datatype);
ALTER TABLE:

Modifies the structure of an existing table.


Example: ALTER TABLE table_name ADD column_name datatype;
DROP TABLE:Deletes an existing table and its data.
Example: DROP TABLE table_name;
5. SQL Constraints:
Constraints are rules applied to columns to enforce data integrity.
Common constraints include PRIMARY KEY, FOREIGN KEY, NOT NULL,
UNIQUE, etc.
6. SQL Joins:
SQL supports various types of joins (e.g., INNER JOIN, LEFT JOIN, RIGHT
JOIN) to retrieve data from multiple tables based on specified conditions.
7. SQL Functions:
SQL provides a variety of functions for data manipulation and analysis,
such as SUM, AVG, COUNT, MAX, MIN, etc.
8. SQL Indexes:
Indexes are used to improve the speed of data retrieval operations on
database tables.
9. SQL Views:
Views are virtual tables derived from the result of a SELECT query,
simplifying complex queries and enhancing security.
10. SQL Security:
SQL supports user authentication, authorization, and encryption to
ensure the security of the database.
SQL is a fundamental skill for anyone working with databases, and its
syntax is relatively straightforward, making it accessible for beginners
while offering powerful capabilities for advanced users.
Operators In SQL

1. Arithmetic Operators:
Perform basic arithmetic operations on numeric values.

Example:
SELECT column1 + column2 AS sum_result
FROM table_name;
->Common arithmetic operators: '+' (addition), '-' (subtraction), '*'
(multiplication), '/' (division), '%' (modulo).

2. Comparison Operators:
Used to compare values in a WHERE clause of a SQL statement.
Example:
SELECT column1, column2
FROM table_name
WHERE column1 > 100;
->Common comparison operators: '=', '!=' or '<>' (not equal), '<', '>',
'<=', '>=', BETWEEN, LIKE, IN, IS NULL, IS NOT NULL.
3. Logical Operators:
Used to combine multiple conditions in a WHERE clause.
Example:
SELECT column1, column2
FROM table_name
WHERE column1 > 100 AND column2 < 50;
->Common logical operators: AND, OR, NOT.

4. Concatenation Operator:
Used to concatenate (combine) two or more strings into a single string.
Example:
SELECT CONCAT(first_name, ' ', last_name) AS full_name
FROM employees;
Common concatenation operators: || (in some databases), CONCAT()
function.

5. NULL-Related Operators:
Used to check for NULL values.

Example:
SELECT column1
FROM table_name
WHERE column1 IS NULL;
->Common NULL-related operators: IS NULL, IS NOT NULL.

6. Bitwise Operators:
Perform operations on binary representations of numbers.

Example:

SELECT column1 & column2 AS bitwise_and_result


FROM table_name;
->Common bitwise operators: & (bitwise AND), | (bitwise OR), ^
(bitwise XOR), ~ (bitwise NOT).

7. Assignment Operator:
Used to assign a value to a variable or column.

Example:
DECLARE @variable_name INT;
SET @variable_name = 10;
->Common assignment operator: =.
Commands In SQl

Data Definition Language (DDL):

1.CREATE DATABASE:
CREATE DATABASE database_name;

2.USE:
USE database_name;
3.CREAT TABLE:
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
...
);

4.ALTER TALBE:

ALTER TABLE table_name


ADD column_name datatype;
5.DROP TABLE:
DROP TABLE table_name;

Data Manipulation Language (DML):

1.SELECT:

SELECT column1, column2


FROM table_name
WHERE condition;

2.INSERT:

INSERT INTO table_name (column1, column2)


VALUES (value1, value2);

3.UPDATE:

UPDATE table_name
SET column1 = value1
WHERE condition;
4.DELETE:

DELETE FROM table_name


WHERE condition;

Data Query Language (DQL):

1.SELECT DISTINCT:

SELECT DISTINCT column1, column2


FROM table_name;

2.ORDER BY:

SELECT column1, column2


FROM table_name
ORDER BY column1 ASC, column2 DESC;
3.GROUP BY:

SELECT column1, COUNT(*)


FROM table_name
GROUP BY column1;

Data Control Language (DCL):

1.GRANT:

GRANT permission
ON object
TO user;

2.REVOKE:

REVOKE permission
ON object
FROM user;
Transaction Control Language (TCL):

1.COMMIT:

COMMIT;

2.ROLLBACK:

ROLLBACK;

3.SAVEPOINT:

SAVEPOINT savepoint_name;

4.ROLLBACK TO SAVEPOINT:

ROLLBACK TO SAVEPOINT savepoint_name;


Joins In SQL

1. INNER JOIN:
Returns only the rows that have matching values in both tables.
Example:
SELECT employees.employee_id, employees.first_name,
departments.department_name
FROM employees
INNER JOIN departments ON employees.department_id =
departments.department_id;

2. LEFT (OUTER) JOIN:


Returns all rows from the left table and the matching rows from the
right table. If there is no match, NULL values are returned for columns
from the right table.

Example:
SELECT employees.employee_id, employees.first_name,
departments.department_name
FROM employees
LEFT JOIN departments ON employees.department_id =
departments.department_id;
3. RIGHT (OUTER) JOIN:
Returns all rows from the right table and the matching rows from the
left table. If there is no match, NULL values are returned for columns
from the left table.
Example:
SELECT employees.employee_id, employees.first_name,
departments.department_name
FROM employees
RIGHT JOIN departments ON employees.department_id =
departments.department_id;

4. FULL (OUTER) JOIN:


Returns all rows when there is a match in either the left or the right
table. If there is no match, NULL values are returned for columns from
the table without a match.
Example:
SELECT employees.employee_id, employees.first_name,
departments.department_name

FROM employees
FULL JOIN departments ON employees.department_id =
departments.department_id;
5. CROSS JOIN:
Returns the Cartesian product of both tables, i.e., all possible
combinations of rows. It does not use any condition to join the tables.
Example:
SELECT employees.employee_id, employees.first_name,
departments.department_name
FROM employees
CROSS JOIN departments;

6. SELF JOIN:
Joins a table with itself. It is used when a table has a hierarchical
structure or when you want to compare rows within the same table.
Example:

SELECT e1.employee_id, e1.first_name, e2.manager_id


FROM employees e1
LEFT JOIN employees e2 ON e1.manager_id = e2.employee_id;

7. NATURAL JOIN:
Performs a join based on columns with the same name in both tables. It
automatically matches columns with identical names.
Example:

SELECT employees.employee_id, employees.first_name,


departments.department_name
FROM employees
NATURAL JOIN departments;

7. NATURAL JOIN:
Performs a join based on columns with the same name in both tables. It
automatically matches columns with identical names.
Example:

SELECT employees.employee_id, employees.first_name,


departments.department_name
FROM employees

NATURAL JOIN departments;

8. UNION JOIN:

Combines the results of two SELECT statements, treating them as sets.


It does not involve joining tables based on columns.
Example:

SELECT employee_id, first_name FROM employees


UNION
SELECT employee_id, first_name FROM other_employees;

You might also like