Database_Unit_Notes
Database_Unit_Notes
1. Introduction to Databases
- Definition: A database is an organized collection of data.
- Examples: Banking systems, e-commerce websites.
- DBMS: Software to manage databases (e.g., MySQL, Oracle).
2. Types of Databases
1. Relational Databases:
- Data is stored in tables (rows and columns).
- Example: MySQL, PostgreSQL.
2. NoSQL Databases:
- For unstructured data (e.g., MongoDB, Cassandra).
3. Distributed Databases:
- Data stored across multiple servers (e.g., Apache Cassandra).
4. Cloud Databases:
- Hosted on platforms like AWS and Google Cloud.
3. Database Architecture
- Single-Tier: Database and application on one machine.
- Two-Tier: Client and server interact directly.
- Three-Tier: Layers for presentation, logic, and database.
4. Components of a DBMS
- Database Engine: Handles storage, retrieval, and updates.
- Query Processor: Converts SQL to machine instructions.
- Transaction Management: Ensures consistency in operations.
- Metadata: Data about data (e.g., table names, data types).
5. Database Design
- Conceptual Design: Use Entity-Relationship Diagrams (ERDs).
- Logical Design: Convert ERDs to tables, follow normalization.
- Physical Design: Implement tables, indexes in the DBMS.
6. Keys in Databases
- Primary Key: Unique identifier for table records.
- Foreign Key: Links two tables via a primary key.
- Composite Key: Combines multiple columns for unique identification.
7. SQL (Structured Query Language)
- DDL: CREATE, ALTER, DROP tables.
- DML: INSERT, UPDATE, DELETE records.
- DQL: SELECT data.
- DCL: GRANT and REVOKE permissions.
8. Normalization
- 1NF: Eliminate duplicate columns, ensure atomic data.
- 2NF: Non-key attributes depend on the entire primary key.
- 3NF: Eliminate transitive dependencies.
9. Transactions
- Properties (ACID):
- Atomicity: All operations succeed or none do.
- Consistency: Maintains database validity.
- Isolation: Transactions don't interfere with each other.
- Durability: Changes persist after system failures.
10. Indexing
- Speeds up data retrieval.
- Clustered Index: Sorts data physically.
- Non-Clustered Index: Creates logical order without altering physical order.