ITF+ Databases Notes
1. What is a Database?
- Definition:
- A database is an organized collection of data that can be accessed, managed, and updated efficiently.
- Purpose:
- To store data in a structured format for easy retrieval and manipulation.
- Examples:
- E-commerce websites storing product and customer data.
- Banking systems managing account transactions.
2. Types of Databases
- Relational Databases:
- Data is organized into tables with rows and columns.
- Example: MySQL, PostgreSQL.
- Non-Relational (NoSQL) Databases:
- Data is stored in flexible formats such as documents or key-value pairs.
- Example: MongoDB, DynamoDB.
- Cloud-Based Databases:
- Hosted on cloud platforms for scalability and accessibility.
- Example: Google Cloud Firestore, Amazon RDS.
- Flat File Databases:
- Simple text files storing data in plain text or CSV format.
- Example: Config files or CSV files.
3. Key Components of Databases
- Tables:
- Structure for organizing data into rows (records) and columns (fields).
- Records (Rows):
- Individual entries in a table.
- Example: A single customer’s details.
- Fields (Columns):
- Specific attributes of data.
- Example: Name, email, phone number.
- Keys:
- Primary Key: Unique identifier for records (e.g., Customer ID).
- Foreign Key: Links records between tables.
4. Database Management Systems (DBMS)
- Definition:
- Software that enables users to interact with databases.
- Examples:
- Relational DBMS: MySQL, PostgreSQL, Oracle Database.
- NoSQL DBMS: MongoDB, Couchbase.
- Cloud-Based DBMS: Amazon RDS, Google BigQuery.
- Features:
- Data storage, querying, backup, and access control.
5. SQL vs. NoSQL
- SQL (Structured Query Language):
- Used in relational databases.
- Focuses on structured data with predefined schemas.
- Example: MySQL, PostgreSQL.
- NoSQL:
- Flexible schemas for unstructured data.
- Suitable for big data and real-time applications.
- Example: MongoDB, Cassandra.
- Key Differences:
- SQL: Relational, structured, uses tables.
- NoSQL: Non-relational, flexible, uses documents, key-value pairs, or graphs.
6. Data Storage and Retrieval
- Queries:
- SQL Example:
SELECT * FROM customers WHERE city='New York';
.
- NoSQL Example: Querying documents in MongoDB.
- Indexing:
- Improves data retrieval speed by creating a structure for faster lookups.
- Data Relationships:
- Linking tables in relational databases using primary and foreign keys.
7. Database Security
- Access Control:
- Use roles and permissions to restrict access to sensitive data.
- Encryption:
- Protects data at rest (on disk) and in transit (network).
- Backups:
- Regularly backing up databases to prevent data loss.
- Authentication:
- Enforcing strong user authentication (e.g., multi-factor authentication).
8. Questions for Review
- What is the difference between relational and non-relational databases?
- How are tables, records, and fields related in a database?
- What are primary and foreign keys, and why are they important?