Database system basic
Database system basic
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 Integrity: Ensures that the data stored is accurate and consistent.
---
2. Types of Databases
Relational Database:
Data is stored in a tree-like structure, where each record has a single parent.
Network Database:
Object-Oriented Database:
---
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.
Foreign Key: A key that links to the primary key of another table.
Entity-Relationship (ER) Model:
ER Diagram:
---
4. Database Design
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.
---
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:
COMMIT;
ROLLBACK;
---
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.
Foreign Key: Links a record in one table to a primary key in another table.
Unique: Ensures all values in a column are unique.
---
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).
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.
---
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.
---
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.
Types of Indexes:
---
Authentication: Verifying the identity of a user before granting access to the database.
---