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

Database system basic

The document provides an overview of databases, including definitions, types, and functions of Database Management Systems (DBMS). It covers database models, design principles, SQL commands, data integrity, transactions, backup and recovery, indexing, and security measures. Key concepts such as normalization, ACID properties, and user access control are also discussed.

Uploaded by

Zia Khan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Database system basic

The document provides an overview of databases, including definitions, types, and functions of Database Management Systems (DBMS). It covers database models, design principles, SQL commands, data integrity, transactions, backup and recovery, indexing, and security measures. Key concepts such as normalization, ACID properties, and user access control are also discussed.

Uploaded by

Zia Khan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

---

1. Introduction to Databases

Database: A database is an organized collection of data that can be easily accessed, managed,
and updated. Databases store data in tables, which are made up of rows and columns.

Database Management System (DBMS): A DBMS is a software system that enables users to
define, create, manage, and manipulate databases. It acts as an intermediary between users
and the database to ensure data is stored and retrieved efficiently and securely.

Functions of DBMS:

Data Storage: Stores data in an efficient, structured format.

Data Retrieval: Provides ways to search and retrieve data quickly.

Data Integrity: Ensures that the data stored is accurate and consistent.

Data Security: Protects data from unauthorized access.

Backup and Recovery: Provides mechanisms to restore data after a failure.

Concurrency Control: Manages multiple users accessing the data simultaneously.

---

2. Types of Databases

Relational Database:

Data is stored in tables (also called relations).

Each table is made up of rows (records) and columns (fields).

Example systems: MySQL, Oracle, PostgreSQL, Microsoft SQL Server.


Hierarchical Database:

Data is stored in a tree-like structure, where each record has a single parent.

Relationships are one-to-many (e.g., one department has many employees).

Example system: IBM's Information Management System (IMS).

Network Database:

Data is stored in a graph structure, with multiple relationships between records.

More flexible than hierarchical databases.

Example system: CODASYL DBMS.

Object-Oriented Database:

Data is stored as objects (similar to objects in Object-Oriented Programming).

Allows more complex data types to be stored (e.g., images, videos).

Example system: ObjectDB.

---

3. Database Models

Relational Model:

Involves tables, with data stored in rows (tuples) and columns (attributes).

Relationships between tables are established through primary and foreign keys.

Primary Key: A unique identifier for each record in a table.

Foreign Key: A key that links to the primary key of another table.
Entity-Relationship (ER) Model:

A conceptual framework used for designing databases.

Entities: Objects or concepts (e.g., Students, Employees).

Attributes: Properties or characteristics of entities (e.g., name, age).

Relationships: Associations between entities (e.g., a student enrolls in a course).

ER Diagram:

Entities are represented by rectangles.

Relationships are represented by diamonds.

Attributes are represented by ellipses.

Cardinality of relationships is indicated (e.g., one-to-many, many-to-many).

---

4. Database Design

Normalization: The process of organizing data to reduce redundancy and dependency. It


involves breaking large tables into smaller, manageable ones.

Normal Forms:

1st Normal Form (1NF): Ensures that each column contains atomic (indivisible) values, and
each record is unique.

2nd Normal Form (2NF): Ensures that each non-key column is fully functionally dependent on
the entire primary key (removes partial dependency).

3rd Normal Form (3NF): Ensures that no transitive dependencies exist (non-key columns
depend only on the primary key).

Boyce-Codd Normal Form (BCNF): Every determinant in the table is a candidate key.
---

5. SQL (Structured Query Language)

SQL is the standard language used to interact with relational databases. SQL allows you to
query, insert, update, and delete data in a database.

SQL Commands:

DML (Data Manipulation Language):

SELECT: Retrieve data from a table.

SELECT column_name1, column_name2 FROM table_name;

INSERT: Insert new data into a table.

INSERT INTO table_name (column_name1, column_name2)


VALUES (value1, value2);

UPDATE: Modify existing data in a table.

UPDATE table_name SET column_name1 = value1 WHERE condition;

DELETE: Remove data from a table.

DELETE FROM table_name WHERE condition;

DDL (Data Definition Language):

CREATE: Create a new table, database, or view.

CREATE TABLE table_name (column_name datatype);

ALTER: Modify an existing table (e.g., add, delete, or modify columns).

ALTER TABLE table_name ADD column_name datatype;

DROP: Delete a table, database, or view.


DROP TABLE table_name;

DCL (Data Control Language):

GRANT: Give a user access privileges.

GRANT SELECT, INSERT ON table_name TO user_name;

REVOKE: Remove user privileges.

REVOKE SELECT, INSERT ON table_name FROM user_name;

TCL (Transaction Control Language):

COMMIT: Save changes made during the current transaction.

COMMIT;

ROLLBACK: Undo changes made during the current transaction.

ROLLBACK;

---

6. Data Integrity and Constraints

Data Integrity: Ensures the accuracy and consistency of data. Key components:

Entity Integrity: Ensures that each table has a primary key, and no primary key values are null.

Referential Integrity: Ensures that foreign keys match primary keys in related tables.

Constraints: Rules applied to data to maintain integrity.

Primary Key: Uniquely identifies each record.

Foreign Key: Links a record in one table to a primary key in another table.
Unique: Ensures all values in a column are unique.

Not Null: Ensures a column cannot have a null value.

Check: Ensures values in a column satisfy a condition.

---

7. Transactions and Concurrency Control

Transaction: A sequence of one or more SQL operations that must be executed as a single unit.
If one operation fails, the entire transaction is rolled back.

ACID Properties:

Atomicity: A transaction is atomic, meaning it either completes fully or doesn't happen at all.

Consistency: The database must remain in a consistent state before and after the transaction.

Isolation: Transactions must be isolated from one another (changes made by one transaction
should not be visible to others until committed).

Durability: Once a transaction is committed, its changes are permanent.

Concurrency Control: Manages access to the database by multiple users to avoid conflicts.

Locking: Ensures that no two transactions access the same data at the same time.

Deadlock: A situation where two or more transactions are blocked, waiting for each other to
release locks.

---

8. Backup and Recovery

Backup: The process of creating copies of the database to protect against data loss.
Full Backup: Backs up the entire database.

Incremental Backup: Backs up only the changes since the last backup.

Recovery: The process of restoring the database from a backup or transaction log after a
failure.

Point-in-Time Recovery: Restoring the database to a specific point in time.

---

9. Indexing

Index: A data structure that improves the speed of data retrieval operations. It is created on one
or more columns in a table.

Primary Index: Automatically created on the primary key column of a table.

Secondary Index: Created on non-primary key columns to speed up searches on those


columns.

Types of Indexes:

Single-level index: A simple index with one level of pointers.

Multi-level index: Uses multiple levels to store indexes.

---

10. Database Security

Authentication: Verifying the identity of a user before granting access to the database.

Authorization: Determining what actions a user is allowed to perform.


GRANT and REVOKE commands are used for managing access control.

---

You might also like