DATABASE
DATABASE
A database is a structured collection of data organized in a way that allows for efficient
storage, retrieval, and management of information. It serves as a centralized repository
for storing and managing data, making it easy to organize, update, and retrieve
information as needed. Databases are a critical component of information systems and
are widely used in various applications, ranging from simple desktop databases to large-
scale enterprise systems.
1. Tables: Databases are often organized into tables, which represent entities (such
as customers, products, or employees) and their attributes. Each table consists of
rows and columns, where each row corresponds to a record, and each column
represents a specific attribute or field.
2. Records: A record is a complete set of related data in a database table. It
contains information about a particular entity or item, represented by the
columns within the table.
3. Fields: Fields are the individual data elements or attributes within a record. They
represent specific pieces of information about the entity being stored.
4. Relations: In relational databases, tables can be related to each other based on
common fields. Establishing relationships between tables enables the creation of
more complex and efficient databases.
5. Queries: Users can retrieve specific information from a database using queries.
Queries allow for the selection, filtering, and sorting of data based on certain
criteria.
6. Indexes: Indexes are data structures that improve the speed of data retrieval
operations on a database table. They help optimize queries by providing a faster
way to locate specific rows.
1. Data Definition: DBMS allows users to define the structure of the database,
including the creation of tables, specifying data types for fields, and establishing
relationships between tables. This is typically done using a data definition
language (DDL).
2. Data Manipulation: DBMS provides a data manipulation language (DML) that
allows users to interact with the data stored in the database. Users can insert,
update, delete, and retrieve data using queries and commands.
3. Data Integrity: DBMS enforces data integrity by imposing rules and constraints
on the data. This ensures that the data stored in the database is accurate,
consistent, and meets specified criteria.
4. Security and Authorization: DBMS provides mechanisms for controlling access to the
database and protecting sensitive information. It includes user authentication,
authorization, and auditing features to ensure data security.
5. Backup and Recovery: DBMS includes tools and features for backing up and recovering
data. This is crucial for ensuring data availability and minimizing the risk of data loss due
to system failures or errors.
RELATIONSHIP IN DATABASE
In a database, a relationship refers to the connection between tables based on
common fields. These relationships define how data in one table is related to data in
another table, facilitating the organization and retrieval of information. There are
different types of relationships, and two important concepts associated with
relationships are "cardinality" and "modality."
1. Cardinality:
• Definition: Cardinality defines the number of related records that each
side of a relationship can have. It describes the maximum and minimum
number of occurrences of one entity that can be associated with another
entity.
• Examples:
• One-to-One (1:1): A person has exactly one passport, and a
passport belongs to only one person. In database terms, this is
represented as a 1:1 relationship.
• One-to-Many (1:N): A department has many employees, but an
employee belongs to only one department. This is represented as a
1:N relationship.
• Many-to-One (N:1): Many students attend one school, but a
school can have many students. This is also represented as a 1:N
relationship.
2. Modality:
• Definition: Modality defines the minimum participation requirements of
entities in a relationship. It specifies whether an entity is optional or
mandatory in a relationship.
• Examples:
• Optional Participation: In a "Customer" and "Order" relationship, a
customer might not have any orders (0..N), indicating optional
participation.
• Mandatory Participation: In a "Department" and "Employee"
relationship, every employee must belong to a department (1..N),
indicating mandatory participation.
Examples: