LABE MANUALOF DISTRIBUTED DATABASE SYSTEM
LABE MANUALOF DISTRIBUTED DATABASE SYSTEM
Name:
Naqeeb Hyder
Roll No:
586411
Program:
BSCS 6th
Section:
2020-2024
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.
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):
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:
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
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:
1.SELECT:
2.INSERT:
3.UPDATE:
UPDATE table_name
SET column1 = value1
WHERE condition;
4.DELETE:
1.SELECT DISTINCT:
2.ORDER BY:
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:
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;
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;
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:
7. NATURAL JOIN:
Performs a join based on columns with the same name in both tables. It
automatically matches columns with identical names.
Example:
7. NATURAL JOIN:
Performs a join based on columns with the same name in both tables. It
automatically matches columns with identical names.
Example:
8. UNION JOIN: