You are on page 1of 29

Chapter 1

Data refers to raw facts, symbols, or values that have little or no meaning on their own. Data
can be in the form of numbers, text, images, sounds, or any other representation of facts.
Example: A series of numbers (e.g., 5, 10, 15, 20) or a collection of letters (e.g., A, B, C, D) are
examples of data.

Information is data that has been processed, organized, and contextualized to make it
meaningful, relevant, and useful. It provides insight, knowledge, or understanding. Example:
When the numbers 5, 10, 15, and 20 are organized and presented as "These are the scores of four
students on a test: Student A scored 5, Student B scored 10, Student C scored 15, and Student D
scored 20," it becomes information that conveys test scores for specific students.

What is DBBS? How Does DBMS differ from a file processing


system?
A Database Management System (DBMS) is a software system that facilitates the organization,
storage, retrieval, and management of data in a structured way. It serves as an intermediary
between the user and the database, allowing users and applications to interact with the data
without needing to know the underlying details of how the data is stored and organized. Here are
the key components and functions of a DBMS: Data Storage, Data Retrieval, Data Manipulation,
Data Security, Data Indexing, Backup and Recovery, Data Integrity, Data Modeling, Query
Optimization.
Database Applications Examples
Database applications are widely used in various domains to manage and organize data
efficiently. Here are some examples of database applications across different fields:
1. Enterprise Resource Planning (ERP) Systems: ERP systems like SAP, Oracle E-
Business Suite, and Microsoft Dynamics use databases to integrate and manage various business
processes such as finance, human resources, inventory, and supply chain management.
2. Customer Relationship Management (CRM): CRM software like Salesforce and
HubSpot use databases to store customer data, interactions, and sales leads, enabling businesses
to manage customer relationships and track sales opportunities.
3. Content Management Systems (CMS): CMS platforms like WordPress and Drupal use
databases to store and manage website content, including articles, images, and user data.
4. E-commerce Platforms: E-commerce websites like Shopify and Magento rely on
databases to manage product catalogs, customer information, orders, and payment processing.
5. Inventory Management Systems: Inventory management systems use databases to track
product quantities, monitor stock levels, and manage supply chain operations efficiently.
6. Healthcare Information Systems: Electronic Health Records (EHR) systems store
patient records, medical history, and treatment information in databases to facilitate healthcare
data management.
7. Educational Systems: Educational institutions use databases to manage student records,
grades, course schedules, and teacher information in systems like Student Information Systems
(SIS).
8. Banking and Financial Systems: Banks use databases to store customer accounts,
transaction records, and financial data, ensuring secure and accurate management of financial
information.
9. Human Resources Management: HR systems maintain employee records, payroll
information, and benefits data in databases to streamline HR operations.
10. Flight Reservation Systems: Airlines and travel agencies use databases to manage flight
schedules, passenger reservations, and ticketing information for efficient booking and
management.
11. Library Catalogs: Libraries use databases to catalog books, periodicals, and other
resources, allowing users to search and locate materials easily.
12. Manufacturing and Supply Chain Management: Manufacturing companies use
databases for production planning, quality control, inventory management, and supply chain
optimization.
13. Social Media Platforms: Social media platforms like Facebook, Twitter, and Instagram
use databases to store user profiles, posts, comments, and other user-generated content.
14. Government Systems: Government agencies use databases for various purposes,
including tax collection, census data management, and public records.
15. Research and Scientific Data: Research institutions use databases to store and analyze
scientific data, research findings, and experiment results.
16. Online Gaming: Online gaming platforms use databases to store user accounts, game
progress, and leaderboards.
17. Weather Forecasting: Meteorological agencies use databases to store and analyze vast
amounts of weather data for accurate forecasting.
18. Agriculture and Farm Management: Farm management systems use databases to track
crop yields, soil conditions, and equipment maintenance.
19. Energy Management Systems: Utilities use databases to monitor and manage energy
consumption, grid operations, and power distribution.
20. Emergency Services: Emergency response systems use databases to store location data,
emergency contact information, and incident reports for quick response during emergencies.

Data abstraction refers to the process of hiding the complex underlying details of the
database system from users and applications while providing a simplified and consistent view of
the data. It involves creating a level of abstraction that separates the physical storage of data from
its logical
• Physical level. The lowest level of abstraction describes how the data are actually
stored. The physical level describes complex low-level data structures in detail.
• Logical level. The next-higher level of abstraction describes what data are stored
in the database, and what relationships exist among those data. The logical level
thus describes the entire database in terms of a small number of relatively simple
structures. Although implementation of the simple structures at the logical level
may involve complex physical-level structures, the user of the logical level does not
need to be aware of this complexity. This is referred to as physical data indecency.
• View level. The highest level of abstraction describes only part of the entire database.
Even though the logical level uses simpler structures, complexity remains
because of the variety of information stored in a large database. Many users of the
database system do not need all this information; instead, they need to access only
a part of the database. The view level of abstraction exists to simplify their interaction
with the system. The system may provide many views for the same database.
Purpose of Database Systems
Database systems serve a fundamental role in modern information technology and business
operations. Their primary purpose is to efficiently and securely manage large volumes of data,
making it accessible, organized, and available for various applications and users. Here are some
key purposes and benefits of database systems:
Data Organization: Database systems provide a structured and organized way to store and
manage data. Data is typically organized into tables with rows and columns, making it easier to
categorize and retrieve information.
Data Retrieval: Users can easily retrieve specific data using queries and search criteria, enabling
efficient access to relevant information without the need for manual data sorting or searching
through files.
Data Integrity: Database systems enforce data integrity constraints, such as unique keys and
referential integrity, to ensure data accuracy and consistency. This helps prevent data duplication
and maintain data quality.
Data Security: Database systems offer security features like user authentication and
authorization, encryption, and access control to protect sensitive data from unauthorized access
and tampering.
Concurrency Control: In multi-user environments, database systems manage concurrent access
to data to prevent conflicts and ensure data consistency. This is crucial for collaborative work
and transaction processing.
Data Redundancy Reduction: Databases minimize data redundancy by storing information in a
centralized manner. This reduces storage space requirements and decreases the chances of
inconsistent data.
Data Abstraction: Database systems provide a level of abstraction, separating the physical
storage details from the logical view of data. This abstraction simplifies data management and
allows changes to the database structure without affecting applications.
Scalability: Database systems can scale to accommodate growing data volumes and increasing
user loads. This scalability is essential for businesses and applications that expect data growth
over time.
Data Backup and Recovery: Database systems offer tools and mechanisms for regular data
backups and recovery procedures to safeguard against data loss due to hardware failures,
accidents, or other unforeseen events.
Data Analysis: Database systems support data analysis through SQL queries and reporting tools,
enabling businesses to gain insights, make informed decisions, and identify trends in their data.
Data Sharing: Multiple users and applications can access and share data from a central
repository. This promotes collaboration and consistency across an organization.
Data Independence: Database systems allow changes to the database structure without affecting
the applications using the data. This separation of data and application logic simplifies software
maintenance.
Support for Complex Queries: Database systems can handle complex queries involving
multiple tables and conditions, enabling users to retrieve specific data subsets efficiently.
Data Durability: Data changes made within a database are durable, meaning they persist even in
the event of system failures or crashes.
Data Compliance: Database systems can help organizations adhere to regulatory requirements
by providing features for data auditing, tracking, and reporting.
Database systems are foundational to various applications and industries, including business,
healthcare, finance, education, research, and more. Their purpose is to ensure data reliability,
availability, and accessibility while supporting the evolving needs of organizations and users.

 Attributes are the properties or characteristics of entities. e.g.; ROLL_NO, NAME etc.
 Entity refers to a real-world object, concept, or thing that is distinguishable and can be
uniquely identified. Entities are fundamental building blocks used to represent and organize
data within a database
 Tuple: Each row in the relation is known as tuple. The above relation contains 4 tuples,
one of which is shown as:
1 RAM DHAKA 9455123451
Data Models
Data modeling in Database Management Systems (DBMS) is the process of creating an abstract
representation (a model) of the data and its relationships within an organization or system. This
representation serves as a blueprint for designing the structure of a database, defining how data
elements are organized, stored, accessed, and related to each other. Data modeling is a crucial
step in database development, as it helps ensure that the database accurately reflects the real-
world domain it represents.
• Relational Model: The relational model uses a collection of tables to represent both
data and the relationships among those data. Each table has multiple columns, and
each column has a unique name. Tables are also known as relations. The relational
model is an example of a record-based model. Record-based models are so named
because the database is structured in fixed-format records of several types. Each
table contains records of a particular type. Each record type defines a fixed number
of fields, or attributes. The columns of the table correspond to the attributes of the
record type. The relational data model is the most widely used data model, and
a vast majority of current database systems are based on the relational model.
• Entity-Relationship Model: The entity-relationship (E-R) data model uses a collection
of basic objects, called entities, and relationships among these objects. An entity
is a “thing” or “object” in the real world that is distinguishable from other
objects. The entity-relationship model is widely used in database design.
• Semi-structured Data Model: The semi-structured data model permits the specification
of data where individual data items of the same type may have different
sets of attributes. This is in contrast to the data models mentioned earlier, where
every data item of a particular type must have the same set of attributes. JSON and
Extensible Markup Language (XML) are widely used semi-structured data representations.
• Object-Based Data Model: Object-oriented programming (especially in Java, C++,
or C#) has become the dominant software-development methodology. This led
initially to the development of a distinct object-oriented data model, but today the
concept of objects is well integrated into relational databases. Standards exist to
store objects in relational tables. Database systems allow procedures to be stored
in the database system and executed by the database system. This can be seen as
extending the relational model with notions of encapsulation, methods, and object identity.
 The collection of information stored in the database at a particular moment is called an
Instance of the database.

A logical container or blueprint that defines the structure, organization, and attributes of a
database Schema.

• Physical Schema: The physical schema, also known as the physical data model, defines
how data is physically stored on storage devices such as disks or memory. Specifies data
file organization, indexing methods, storage structures (e.g., B-trees, hash tables), and
access paths. It addresses issues like data compression, partitioning, and clustering.
Example: Defining how tables are stored on specific hard drives, the organization of data blocks
within those files, and the indexing structures used to speed up queries.
• Logical Schema: The logical schema, also known as the logical data model, defines the
structure of the data and how it is related, without specifying how it will be stored or
accessed physically. Describes tables, attributes, relationships, keys, constraints, and
views without concerning itself with the physical storage details. It serves as a bridge
between the physical schema and the application schema.
Example: Defining tables, relationships, and constraints in an Entity-Relationship Diagram
(ERD) or a relational schema, without specifying how the data will be physically stored.

A Data Definition Language (DDL) is a subset of SQL (Structured Query


Language) used to define and manage the structure of a database, including tables, indexes,
constraints, and other database objects. DDL statements are used to create, alter, and delete
database schema elements. Example:
create table instructor (
ID char (5),
name varchar (20),
department varchar (20),
salary numeric (8,2))
Here are some common DDL statements and their purposes:
• CREATE TABLE: This statement is used to create a new table in the database,
specifying the table's name, column names, data types, and constraints.
• ALTER TABLE: This statement is used to modify an existing table's structure, such as
adding, modifying, or deleting columns, constraints, or indexes.
• DROP TABLE: This statement is used to delete an existing table and all its data from the
database.
• CREATE INDEX: CREATE INDEX is used to create an index on one or more columns
of a table. Indexes improve query performance by allowing faster data retrieval.

The Relational Data Model is a conceptual framework to represent and manage data
in a structured manner. It is based on the principles of set theory and mathematical relations,
Example-
A Data Manipulation Language (DML) is a language that enables users to
access or manipulate data as organized by the appropriate data model. The types of access are:
• Retrieval of information stored in the database.
• Insertion of new information into the database.
• Deletion of information from the database.
• Modification of information stored in the database.
 Integrity: The SQL DDL includes commands for specifying integrity constraints that the
data stored in the database must satisfy. Updates that violate integrity constraints are
disallowed.
 View definition: The SQL DDL includes commands for defining views.
 Transaction control: SQL includes commands for specifying the beginning and end points
of transactions.
 Embedded SQL and dynamic SQL: Embedded and dynamic SQL define how SQL
statements can be embedded within general-purpose programming languages, such as C,
C++, and Java.
 Authorization: The There are basically two types of data-manipulation language:
• Procedural DMLs require a user to specify what data are needed and how to get those
data.
• Declarative DMLs (also referred to as nonprocedural DMLs) require a user to specify
what data are needed without specifying how to get those data. Declarative DMLs are
usually easier to learn and use than are procedural DMLs. However, since a user does
not have to specify how to get the data, the database system has to figure out an
efficient means of accessing data
Key components and operations of DML include:
SELECT: The statement is used to retrieve data from one or more database tables. It allows
users to specify the columns they want to retrieve and apply conditions to filter the results.
SELECT is primarily used for querying and reporting.
Ex-
SELECT FirstName, LastName FROM Employees
WHERE Department = 'Sales';
INSERT: The statement is used to add new records (rows) to a database table. Users provide
values for each column in the table to insert a new row.
Ex-
INSERT INTO Customers (CustomerID, FirstName, LastName, Email)
VALUES (101, 'John', 'Doe', 'john.doe@email.com');
UPDATE: The statement is used to modify existing records in a database table. Users
specify the columns to be updated and the new values. Conditions can be used to identify the
rows to be updated.
Ex-
UPDATE Products
SET Price = 24.99
WHERE ProductID = 123;
DELETE: The statement is used to remove one or more records from a database table. Users
can specify conditions to identify the rows to be deleted.
Ex-
DELETE FROM Orders
WHERE OrderID = 456;

A Query is a statement requesting the retrieval of information. The portion of a DML that
involves information retrieval is called a query language

Structured query language (SQL) is a programming language for storing and


processing information in a relational database. A relational database stores information in
tabular form, with rows and columns representing different data attributes and the various
relationships between the data values. If we want to retrieve attributes ROLL_NO and
NAME of all students, the query will be:
ROLL_NO Name
1 Arnob
2 Tanvir
3 Anik
Query: SELECT ROLL_NO, NAME FROM STUDENT
WHERE ROLL_NO>2;
Result:
ROLL_NO Name
3 Anik

Database design is the process of creating a structured plan or blueprint for how a
database system will store, organize, and manage data. It involves making critical decisions
about the structure, organization, and relationships of data within a database to meet specific
business or application requirements efficiently and accurately. Database Schema-
A Database engine is a software component or system responsible for the core
functionality of storing, managing, and retrieving data in a database. The functional components
of a database system can be broadly divided into the storage manager, the query processor
components, and the transaction management component.

The Storage manager is the component of a database system that provides the interface
between the low-level data stored in the database and the application programs and
queries submitted to the system. The storage manager is responsible for the interaction
with the file manager. The raw data are stored on the disk using the file system provided
by the operating system. The storage manager translates the various DML statements
into low-level file-system commands. Thus, the storage manager is responsible for storing,
retrieving, and updating data in the database.
The storage manager components include:
• Authorization and integrity manager, which tests for the satisfaction of integrity
constraints and checks the authority of users to access data.
• Transaction manager, which ensures that the database remains in a consistent
(correct)
state despite system failures, and that concurrent transaction executions proceed
without conflicts.
• File manager, which manages the allocation of space on disk storage and the data
structures used to represent information stored on disk.
• Buffer manager, which is responsible for fetching data from disk storage into main
memory, and deciding what data to cache in main memory. The buffer manager is
a critical part of the database system, since it enables the database to handle data
sizes that are much larger than the size of main memory.
The storage manager implements several data structures as part of the physical
system implementation:
• Data files, which store the database itself.
• Data dictionary, which stores metadata about the structure of the database, in
particular the schema of the database.
• Indices, which can provide fast access to data items. Like the index in this textbook,
a database index provides pointers to those data items that hold a particular value.
For example, we could use an index to find the instructor record with a particular
ID, or all instructor records with a particular name.

A Query processor is a fundamental component of a Database Management System


(DBMS) responsible for interpreting, optimizing, and executing database queries. Its primary
function is to translate user or application queries written in SQL (Structured Query Language)
into a series of steps that the database engine can execute efficiently.
The query processor components include:
• DDL interpreter, which interprets DDL statements and records the definitions in
the data dictionary.
• DML compiler, which translates DML statements in a query language into an
evaluation
plan consisting of low-level instructions that the query-evaluation engine
understands. A query can usually be translated into any of a number of alternative evaluation
plans that all give the same result. The DML compiler also performs query
optimization; that is, it picks the lowest cost evaluation plan from among the alternatives.
• Query evaluation engine, which executes low-level instructions generated by the
DML compiler.

Transaction management is a fundamental concept in the field of Database


Management Systems (DBMS) that refers to the process of ensuring the consistency, integrity,
and reliability of a database in the face of concurrent and potentially conflicting operations
performed by multiple users or applications. Transactions are sequences of one or more database
operations (such as inserts, updates, or deletes) that are treated as a single unit of work.
A transaction is a collection of operations that performs a single logical function
n a database application.
Database and Application Architecture- Database architecture refers to the
structure and organization of the database system itself, including its components and how they
interact. Application architecture, on the other hand, focuses on how software applications are
designed, structured, and interact with each other and with the database.

Earlier-generation database applications used a two-tier architecture, where


the application resides at the client machine, and invokes database system functionality
at the server machine through query language statements. In contrast, modern database
applications use a three-tier architecture, where the client machine acts as merely a front end
and does not contain any direct database calls; web browsers and mobile applications are the
most commonly used application clients today. The front end communicates with an application
server. The application server, in turn, communicates with a database system to access data. The
business logic of the application, which says what actions to carry out under what conditions, is
embedded in the application server, instead of being distributed across multiple clients. Three
tier applications provide better security as well as better performance than two-tier applications.
Database Users and User Interfaces
Database users are individuals or entities who interact with a database management system
(DBMS) to access, manipulate, and manage data stored within a database. These users can be
categorized into several roles based on their specific tasks and responsibilities in relation to the
database. There are four different types of database-system users, differentiated by the way they
expect to interact with the system. Different types of user interfaces have been designed
for the different types of users.
• Na¨ıve users are unsophisticated users who interact with the system by using
predefined
user interfaces, such as web or mobile applications. The typical user interface
for na¨ıve users is a forms interface, where the user can fill in appropriate fields of
the form. Na¨ıve users may also view read reports generated from the database.
As an example, consider a student, who during class registration period, wishes
to register for a class by using a web interface. Such a user connects to a web
application program that runs at a web server. The application first verifies the
identity of the user and then allows her to access a form where she enters the
desired information. The form information is sent back to the web application
at the server, which then determines if there is room in the class (by retrieving
information from the database) and if so adds the student information to the class
roster in the database.
• Application programmers are computer professionals who write application
programs.
Application programmers can choose from many tools to develop user interfaces.
• Sophisticated users interact with the system without writing programs. Instead,
they form their requests either using a database query language or by using tools
such as data analysis software. Analysts who submit queries to explore data in the
database fall in this category.
Database Administrator
One of the main reasons for using DBMSs is to have central control of both the data
and the programs that access those data. A person who has such central control over
the system is called a database administrator (DBA). The functions of a DBA include:
• Schema definition. The DBA creates the original database schema by executing a
set of data definition statements in the DDL.
• Storage structure and access-method definition. The DBA may specify some
parameters
pertaining to the physical organization of the data and the indices to be created.
Schema and physical-organization modification. The DBA carries out changes to the
schema and physical organization to reflect the changing needs of the organization,
or to alter the physical organization to improve performance.
• Granting of authorization for data access. By granting different types of
authorization,
the database administrator can regulate which parts of the database various
users can access. The authorization information is kept in a special system structure
that the database system consults whenever a user tries to access the data in
the system.
• Routine maintenance. Examples of the database administrator’s routine maintenance
activities are:
o Periodically backing up the database onto remote servers, to prevent loss of
data in case of disasters such as flooding.
o Ensuring that enough free disk space is available for normal operations, and
upgrading disk space as required.
o Monitoring jobs running on the database and ensuring that performance is not
degraded by very expensive tasks submitted by some users.
Chapter 2

A Super key is a set of one or more attributes that, taken collectively, allow us to
identify uniquely a tuple in the relation. For example, the ID attribute of the relation
instructor is sufficient to distinguish one instructor tuple from another. Thus, ID is a
super key.
A Primary key is a unique identifier for each record in a table. Example:
Consider a database table named "Students" that stores information about students in a school.
Each student has a unique student ID, and we want to use this unique identifier as the primary
key for the table. Here's what the table might look like:

In this example, the "StudentID" column serves as the primary key for the "Students" table. It
uniquely identifies each student, ensuring that there are no duplicate values in the "StudentID"
column.
A Foreign key establishes a relationship between tables by referencing the primary key of
another table. Example:
consider another table named "Courses" that stores information about various courses offered by
the school. Each course has a course ID, and we want to establish a relationship between students
and the courses they are enrolled in. To do this, we can use a foreign key in the "Courses" table
to reference the "Students" table. Here's what the "Courses" table might look like:

In this example, the "StudentID" column in the "Courses" table is a foreign key that references
the "StudentID" column in the "Students" table. This establishes a relationship between students
and the courses they are enrolled in. The foreign key ensures that the values in the "StudentID"
column of the "Courses" table match values in the "StudentID" column of the "Students" table.
For example, in the "Courses" table:
StudentID 101 (John Smith) is enrolled in Mathematics and History.
StudentID 102 (Emily Johnson) is enrolled in science.
StudentID 103 (Michael Davis) is enrolled in English.
Relational algebra is a theoretical framework and a mathematical foundation for working
with relational databases. It defines a set of operations used to manipulate and query data in
relational database systems. These operations are fundamental for performing various tasks in
database management. Here are the core relational algebra operations:
Selection (σ - Sigma):
The selection operation retrieves rows from a relation (table) that satisfy a specified condition or
predicate. It filters the rows based on a given condition, resulting in a subset of the original
relation.
Example:
σ (Department = 'Sales')(Employees)
Projection (π - Pi):
The projection operation retrieves specific columns (attributes) from a relation while discarding
the rest of the columns. It allows you to create a new relation with a subset of the original
attributes.
Example:
π (FirstName, LastName)(Employees)
Union (∪):
The union operation combines the rows from two relations (tables) into a single result relation. It
eliminates duplicate rows from the result, ensuring that each row is unique.
Example:
Employees ∪ Contractors
Intersection (∩):
The intersection operation returns the common rows between two relations. It retrieves rows that
exist in both relations.
Example:
Employees ∩ Contractors
Difference (-):
The difference operation (also known as set difference or minus) retrieves rows from one relation
that do not exist in another relation. It returns rows that are unique to the first relation.
Example:
Employees - Contractors
Cartesian Product (×):
The cartesian product operation combines every row from the first relation with every row from
the second relation, resulting in a new relation that contains all possible combinations of rows
from both relations.
Example:
Employees × Departments
Join (⨝ - Theta Join):
The join operation combines rows from two relations based on a specified condition. It creates a
new relation by matching rows where the condition is true.
Example:
Employees ⨝ (Employee.Department = Department.Department)(Department)
Rename (ρ - Rho):
The rename operation allows you to change the name of a relation and its attributes. It is often
used for clarity and to avoid naming conflicts in query results.
Example:
ρ (Emp)(Employees)
These relational algebra operations are the building blocks of relational database query languages
like SQL. They provide a formal and mathematical foundation for expressing a wide range of
database operations and queries. More complex queries and expressions can be constructed by
combining these basic operations.
Set operations in the context of relational databases involve operations that allow you to
manipulate and combine data from multiple tables or relations. These operations are fundamental
for querying and retrieving data from a database. There are several types of set operations
commonly used in relational database systems:
1.Union: The union operation combines the rows from two or more tables or queries into a
single result set. It eliminates duplicate rows, ensuring that each row is unique. The columns of
the tables involved in the union must have the same data types.
2.Intersect: The intersection operation returns the common rows between two or more tables or
queries. It retrieves rows that exist in all the specified tables. Like the union operation, the
columns must have the same data types.
3.Except: The difference operation (also known as set difference or minus) retrieves rows from
the first table or query that do not exist in the second table or query. It returns rows that are
unique to the first set.
Example: CODE-
SELECT FirstName, LastName FROM Employees
UNION/INTERCEPT/EXCEPT
SELECT FirstName, LastName FROM Contractors;
Aggregate functions are SQL functions that perform a calculation on a set of values and
return a single value as the result. These functions are commonly used in SQL queries to
summarize and analyze data within database tables. Aggregate functions operate on a group of
rows specified by the GROUP BY clause or on all rows if no grouping is specified. Here are
some common aggregate functions:
• COUNT() calculates the number of rows in a group or a table. It can be used with the
wildcard (*) to count all rows or with a specific column to count non-null values in that
column.
• SUM() calculates the sum of all values in a numeric column within a group or a table.
• AVG() calculates the average (mean) of values in a numeric column within a group or a
table.
• MIN() returns the minimum (smallest) value in a column within a group or a table.
• MAX() returns the maximum (largest) value in a column within a group or a table.
Chapter 7
Types Of Attributes:
1. Key Attribute: The attribute which uniquely identifies each entity in the entity set is
called the key attribute. For example, Roll_No will be unique for each student. In ER
diagram, the key attribute is represented by an oval with underlying lines.
2. Composite Attribute: An attribute composed of many other attributes is called a
composite attribute.

3. Multivalued Attribute: An attribute consisting of more than one value for a given entity.
For example, Phone_No (can be more than one for a given student). In ER diagram, a
multivalued attribute is represented by a double oval. For example, the Address attribute
of the student Entity type consists of Street, City, State, and Country. In ER diagram, the
composite attribute is represented by an oval comprising of ovals.
4. Derived Attribute: An attribute that can be derived from other attributes of the entity
type is known as a derived attribute. e.g.; Age (can be derived from DOB). In ER
diagram, the derived attribute is represented by a dashed oval.

The Complete Entity Type Student with its Attributes can be represented as:

The number of times an entity of an entity set participates in a relationship set is known as
Cardinality. Cardinality can be of different types:
1. One-to-One: When each entity in each entity set can take part only once in the
relationship, the cardinality is one-to-one. Let us assume that a male can marry one
female and a female can marry one male. So the relationship will be one-to-one.
2. One-to-Many: In one-to-many mapping as well where each entity can be related to more
than one relationship and the total number of tables that can be used in this is 2. Let us
assume that one surgeon department can accommodate many doctors. So the Cardinality
will be 1 to M. It means one department has many Doctors.

3. Many-to-One: When entities in one entity set can take part only once in the relationship
set and entities in other entity sets can take part more than once in the relationship set,
cardinality is many to one. Let us assume that a student can take only one course but one
course can be taken by many students. So the cardinality will be n to 1. It means that for
one course there can be n students but for one student, there will be only one course.

4. Many-to-Many: When entities in all entity sets can take part more than once in the
relationship cardinality is many to many. Let us assume that a student can take more than
one course and one course can be taken by many students. So, the relationship will be
many to many.
Give an expression in the relational algebra to express each of the following queries:
employee (person-name, street, city)
works (person-name, company-name, salary)
company (company-name, city)
manages (person-name, manager-name)

You might also like