Database Management Systems: Core Concepts and Principles
Database Management System (DBMS)
A software package or system designed to facilitate the creation and maintenance of a computerized database.
Data Storage in Databases
Data is stored in tables consisting of rows and columns.
Table Relationships and Keys
Tables relate to one another using keys:
- Primary Key (PK): Uniquely identifies a row in a table.
- Foreign Key (FK): Links one table to another.
Records and Constraints
A record (or row) is a single entry containing data for each column in the table. A constraint is a rule that ensures the accuracy and integrity of data (e.g., an age constraint of 17–20 years).
Attributes and Data Independence
An attribute is a property or characteristic of an entity or relationship (e.g., order_date and total_amount). Data independence is the ability to change the database schema without affecting application programs or user queries.
Achieving Data Independence
This is achieved through database abstraction layers and schemas:
- Internal Schema: Physical storage details.
- Conceptual Schema: Logical structure of the data.
- External Schema: The user view of the data.
Data Abstraction
The process of hiding irrelevant details from the user, such as hiding physical storage details while showing only the conceptual view.
Database Languages
- DDL (Data Definition Language): Manages the structure of the database (tables, indexes, etc.).
- DML (Data Manipulation Language): Manages data manipulation (INSERT, UPDATE, SELECT, DELETE).
Entity-Relationship Modeling
- Attribute: A characteristic of an entity or relationship.
- Composite Attribute: An attribute that can be broken down into smaller, specific components.
- Strong Entity: An entity type with a key attribute (e.g., customer_id).
- Weak Entity: An entity that lacks a key attribute and depends on another entity type.
- Partial Key: Uniquely identifies a weak entity within an identifying relationship.
- Identifying Relationship: Relates a weak entity type to an owner entity type.
ER Diagram Symbols
- Entity: Long rectangle.
- Weak Entity: Long rectangle inside another rectangle.
- Relationship: Diamond.
- Identifying Relationship: Diamond inside a diamond.
- Attribute: Long oval.
- Key Attribute: Long oval with an underlined name.
Relationship Cardinality
- 1:1 (One-to-One): Each person has one passport; each passport belongs to one person.
- 1:M (One-to-Many): A customer can place many orders, but each order belongs to one customer.
- N:1 (Many-to-One): Many employees work in a single department.
- M:N (Many-to-Many): Students can enroll in many courses; courses can have many students.
- 0:N (Zero-to-Many): A customer may have zero or many complaints.
Types of Database Constraints
- PRIMARY KEY: Ensures each record is unique and not null.
- FOREIGN KEY: Links tables and maintains referential integrity.
- UNIQUE: Ensures all values in a column are distinct.
- NOT NULL: Prevents empty values in a column.
- CHECK: Ensures values meet a specific condition.
- DEFAULT: Sets a default value if none is provided.
