Database System
Definition:
• A Database Management System (DBMS) is software designed to store, manage,
and retrieve data efficiently. It serves as an interface between users and databases,
ensuring smooth and controlled interaction with the stored data.
OR
• A Database Management System (DBMS) is software that:
• Allows you to define, create, maintain, and control access to a database.
• Acts as a bridge between the user and the data stored in the system.
• Ensures the data is safe, organized, efficiently retrievable, and modification-
friendly.
Key Functions of DBMS:
• Data Storage Management: Organizes data efficiently and stores it in a
structured manner.
• Data Retrieval: Retrieves requested data quickly.
• Data Integrity and Security: Ensures data accuracy, consistency, and protection.
• Backup and Recovery: Helps recover data in case of loss or corruption.
• Concurrency Control: Allows multiple users to access and modify data
simultaneously.
What is a Database?
• A database is a structured collection of data that is stored in a way that it can
be easily accessed, managed, and updated.
• Structure: Databases are often structured in tables (in relational databases),
where data is organized into rows and columns.
• Components of a Database:
• Tables: The fundamental building block of a database where data is stored in
rows and columns.
• Fields (Columns): Define the attributes of the data in the database.
• Records (Rows): Represent individual entries in the table, with each row
containing data for a specific instance of an entity.
• Examples: A customer database in an e-commerce platform or a student record
system in an educational institution.
Database Types/Models
• A database model defines the logical structure of the database and
the relationships between data elements. Common types of database
models include:
• Relational Model:
• Data is stored in tables (relations), with each table consisting
of rows (records) and columns (attributes).
• Primary Key: Uniquely identifies each record.
• Foreign Key: Establishes relationships between tables.
• Normalization: Process of organizing data to reduce
redundancy.
• Hierarchical Model:
• Data is organized in a tree-like structure with one-to-many
relationships.
• Example: Organizing employee data with hierarchical reporting
structures.
• Network Model:
• Data is represented as graphs where records can have multiple
relationships.
• Example: Network-based information systems with multiple complex
interrelationships.
• Object-Oriented Model:
• Data is stored as objects, similar to how data is organized in object-
oriented programming languages.
• Example: Applications that use complex data types like images and
multimedia.
Building Blocks of a Database
• Tables:
The primary structure for storing data in a relational database. Data is
stored in rows and columns, each column representing a field, and each
row representing a record.
• Records:
Each row (record) in a table contains a set of values for the fields
(columns). A record typically represents a real-world entity (e.g., a
customer or product).
• Fields:
• Columns in a table represent attributes of the records. For example, a
customer table might have fields like customer_id, customer_name,
and email_address.
• Primary Key:
• A unique identifier for each record in a table, ensuring there are no
duplicate entries.
• Foreign Key:
• A field in a table that creates a relationship with another table by
referencing the primary key of the other table.
Data Integrity and Constraints
• Data Integrity ensures that data in a database is accurate, consistent, and reliable.
(Integrity refers to the accuracy, consistency, and reliability of the data stored in a database).Constraints
are rules applied to the data in a database to enforce integrity like conditions.
• Types of Integrity Constraints:
• Entity Integrity: Ensures each record in a table is uniquely identifiable (achieved using the
primary key).
• Referential Integrity: Ensures relationships between tables remain consistent (enforced using
foreign keys).
• Domain Integrity: Ensures that values in a column are of the correct type and within an
acceptable range.
• User-Defined Integrity: Enforces rules that are specific to the organization or application.
Database Architecture:
This approach separates the database into three levels: external (user view),
conceptual (database structure), and internal (physical storage).
Database Architectures:
• Single/One-Tier Architecture: The entire application runs on a single
machine, typically a server. (Tier like layers)
This setup is simple and is often used in personal or standalone applications
where the user interacts directly with the database.
For Example: A Microsoft Excel spreadsheet is a great example of one-tier
architecture.
One-Tier Architecture
• Two-Tier Architecture (Client-Server): Applications are divided into
a client (user interface) and a server (database).
• For Example: A Library Management System used in schools or
small organizations is a classic example of two-tier architecture.
• Client Layer (Tier 1): This is the user interface that library staff or
users interact with. For example they might use a desktop application
to search for books, issue them, or check due dates.
• Database Layer (Tier 2): The database server stores all the library
records such as book details, user information, and transaction logs.
Two-Tier Architecture
• Three-Tier Architecture: This architecture separates the application into
presentation, application logic, and data layers, providing flexibility and
maintainability.
• For Example: E-commerce Store
• User(Tier-1): You visit an online store, search for a product and add it to your cart.
• Processing(Tier-2): The system checks if the product is in stock, calculates the
total price and applies any discounts.
• Database(Tier-3): The product details, your cart and order history are stored in the
database for future reference
Three-Tier Architecture