0% found this document useful (0 votes)
68 views

Introduction To DBMS

The document provides an introduction to database management systems (DBMS). It defines DBMS as a collection of interrelated data and programs used to store and access the data efficiently. The need for DBMS is to optimize storage and retrieval of large amounts of data by eliminating redundancy and allowing fast retrieval. DBMS ensure data is stored systematically and retrieved quickly while meeting needs like data security, consistency and flexible access.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views

Introduction To DBMS

The document provides an introduction to database management systems (DBMS). It defines DBMS as a collection of interrelated data and programs used to store and access the data efficiently. The need for DBMS is to optimize storage and retrieval of large amounts of data by eliminating redundancy and allowing fast retrieval. DBMS ensure data is stored systematically and retrieved quickly while meeting needs like data security, consistency and flexible access.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 154

UNIT 1

Introduction to DBMS
Database

 DBMS stands for Database Management System.


 We can break it like this DBMS = Database + Management
System.
 Database is a collection of data and Management System is
a set of programs to store and retrieve those data.
 Based on this we can define DBMS like this: DBMS is a
collection of inter-related data and set of programs to store
& access those data in an easy and effective manner.
What is the need of DBMS?

 Database systems are basically developed for large amount of data.


 When dealing with huge amount of data, there are two things that require optimization:
 Storage of data
 and retrieval of data.
Storage

 According to the principles of database systems, the data is stored in such a way that it
acquires lot less space as the redundant data (duplicate data) has been removed before
storage.
Example

 In a banking system, suppose a customer is having two accounts, one is saving account and
another is salary account. Let’s say bank stores saving account data at one place (these
places are called tables we will learn them later) and salary account data at another place,
in that case if the customer information such as customer name, address etc. are stored at
both places then this is just a wastage of storage (redundancy/ duplication of data), to
organize the data in a better way the information should be stored at one place and both the
accounts should be linked to that information somehow. The same thing we achieve in
DBMS.
Fast Retrieval of data

 Along with storing the data in an optimized and systematic manner, it is also important that
we retrieve the data quickly when needed.
 Database systems ensure that the data is retrieved as quickly as possible.
Purpose of Database Systems

 The main purpose of database systems is to manage the data.


 Consider a university that keeps the data of students, teachers, courses, books etc. To
manage this data we need to store this data somewhere where we can add new data, delete
unused data, update outdated data, retrieve data, to perform these operations on data we
need a Database management system that allows us to store the data in such a way so that
all these operations can be performed on the data efficiently
Database Applications – DBMS

 Applications where we use Database Management Systems are:


 Telecom
 Industry
 Banking System
 Sales
 Airlines
 Education sector
 Online shopping
Drawbacks of File system

 Data redundancy: Data


redundancy refers to the duplication of data, lets say
we are managing the data of a college where a student is enrolled for
two courses, the same student details in such case will be stored twice,
which will take more storage than needed. Data redundancy often leads
to higher storage costs and poor access time.
 Data inconsistency: Data
redundancy leads to data inconsistency, lets take
the same example that we have taken above, a student is enrolled for
two courses and we have student address stored twice, now lets say
student requests to change his address, if the address is changed at one
place and not on all the records then this can lead to data inconsistency.
 Data Isolation: Because
data are scattered in various files, and files may be in
different formats, writing new application programs to retrieve the
appropriate data is difficult.
 Dependency on application programs: Changing files would lead to change in
application programs.
 Atomicity issues: Atomicity
of a transaction refers to “All or nothing”, which
means either all the operations in a transaction executes or none.
 Data Security: Data
should be secured from unauthorized access, for example a
student in a college should not be able to see the payroll details of the teachers,
such kind of security constraints are difficult to apply in file processing systems.
Advantage of DBMS over file system

 No redundant data: Redundancy


removed by data normalization. No data
duplication saves storage and improves access time.
 Data Consistency and Integrity: As
we discussed earlier the root cause of data
inconsistency is data redundancy, since data normalization takes care of the
data redundancy, data inconsistency also been taken care of as part of it.
 Data Security: It
is easier to apply access constraints in database systems so
that only authorized user is able to access the data. Each user has a
different set of access thus data is secured from the issues such as identity
theft, data leaks and misuse of data.
 Privacy: Limited access means privacy of data.
 Easy access to data : Database
systems manages data in such a
way so that the data is easily accessible with fast response
times.

 Easy recovery: Since database systems keeps the backup of data, it is easier to do a full
recovery of data in case of a failure.

 Flexible: Database systems are more flexible than file processing systems.
Disadvantages of DBMS

 DBMS implementation cost is high compared to the file system

 Complexity: Database systems are complex to understand

 Performance: Database systems are generic, making them suitable for various applications.
However this feature affect their performance for some applications
Question?

 What is a database?
a) Organized collection of information that cannot be
accessed, updated, and managed
b) Collection of data or information without organizing
c) Organized collection of data or information that can be
accessed, updated, and managed
d) Organized collection of data that cannot be updated
Question

 What is DBMS?
a) DBMS is a collection of queries
b) DBMS is a high-level language
c) DBMS is a programming language
d) DBMS stores, modifies and retrieves data
Components of DBMS

 Hardware, Software, Data, Database Access Language, Procedures and Users all together
form the components of a DBMS.
Hardware

 When we say Hardware, we mean computer, hard disks, I/O


channels for data, and any other physical component involved
before any data is successfully stored into the memory.

 When we run Oracle or MySQL on our personal computer, then our


computer's Hard Disk, our Keyboard using which we type in all the
commands, our computer's RAM, ROM all become a part of the
DBMS hardware.
Software

 This is the main component, as this is the program which controls


everything. The DBMS software is more like a wrapper around the
physical database, which provides us with an easy-to-use interface
to store, access and update data.

 The DBMS software is capable of understanding the Database


Access Language and interpret it into actual database commands to
execute them on the DB.
Data

 Data is that resource, for which DBMS was designed. The motive
behind the creation of DBMS was to store and utilize data.

 In a typical Database, the user saved Data is present and meta


data is stored.

 Metadata is data about the data. This is information stored by the


DBMS to better understand the data stored in it.
Example

  When I store my Name in a database, the DBMS will store when


the name was stored in the database, what is the size of the name, is
it stored as related data to some other data, or is it independent, all
this information is metadata.
Procedures

 Procedures refer to general instructions to use a database


management system. This includes procedures to setup and install a
DBMS, To login and logout of DBMS software, to manage
databases, to take backups, generating reports etc.
Database Access Language

 Database Access Language is a language used to write


commands to access, update, and delete data stored in a
database.
 Users can write commands using Database Access
Language before submitting them to the database for
execution.
 Through utilizing the language, users can create new
databases, tables, insert data, and delete data.
Users

 Database users are categorized based up on their interaction with the database. 
 These are different types of database users in DBMS:
 Database Administrator (DBA)
 Naive / Parametric End Users
 System Analyst 
 Sophisticated Users
 Database Designers 
 Application Programmers
 Casual Users / Temporary Users
1. Database Administrator (DBA) 

 Database Administrator (DBA) is a person/team who defines the


schema and also controls the 3 levels of database.
 The DBA will then create a new account id and password for the
user if he/she need to access the database.
 DBA is also responsible for providing security to the database and
he allows only the authorized users to access/modify the data base.
 DBA is responsible for the problems such as security breaches and
poor system response time.
• DBA also monitors the recovery and backup and provide technical
support.
• The DBA has a DBA account in the DBMS which called a system
or superuser account.
• DBA repairs damage caused due to hardware and/or software
failures.
• DBA is the one having privileges to perform DCL (Data Control
Language) operations such as GRANT and REVOKE, to
allow/restrict a particular user from accessing the database.
2. Naive / Parametric End Users

 Parametric End Users are the unsophisticated who don’t have any
DBMS knowledge but they frequently use the database applications
in their daily life to get the desired results.
 For examples, Railway’s ticket booking users are naive users.
Clerks in any bank is a naive user because they don’t have any
DBMS knowledge but they still use the database and perform their
given task.
3. System Analyst

 System Analyst is a user who analyzes the requirements of


parametric end users. They check whether all the requirements of
end users are satisfied.
4. Sophisticated Users

 Sophisticated users can be engineers, scientists, business analyst,


who are familiar with the database. They can develop their own
database applications according to their requirement. They don’t
write the program code but they interact the database by writing
SQL queries directly through the query processor.
5. Database Designers

 Data Base Designers are the users who design the structure of
database which includes tables, indexes, views, triggers, stored
procedures and constraints which are usually enforced before the
database is created or populated with data.
 He/she controls what data must be stored and how the data items to
be related.
 It is responsibility of Database Designers to understand the
requirements of different user groups and then create a design which
satisfies the need of all the user groups.
6. Application Programmers

 Application Programmers also referred as System Analysts or


simply Software Engineers, are the back-end programmers who
writes the code for the application programs. They are the computer
professionals.
 These programs could be written in Programming languages such as
Visual Basic, Developer, C, FORTRAN, COBOL etc. Application
programmers design, debug, test, and maintain set of programs
called “canned transactions” for the Naive (parametric) users in
order to interact with database.
7. Casual Users / Temporary Users

 Casual Users are the users who occasionally use/access the database
but each time when they access the database they require the new
information.
 For example, Middle or higher level manager.
DBMS Architecture

 . Database management systems architecture will help us understand the components of


database system and the relation among them.
 The architecture of DBMS depends on the computer system on which it runs.
 For example, in a client-server DBMS architecture, the database systems at server machine
can run several requests made by client machine.
 We will understand this communication with the help of diagrams.
Types of DBMS Architecture

 There are three types of DBMS architecture:

1. Single tier architecture

2. Two tier architecture

3. Three tier architecture


Single tier architecture

 In this type of architecture, the database is readily available on the client machine, any
request made by client doesn’t require a network connection to perform the action on the
database.
 For example, lets say you want to fetch the records of employee from the database and the
database is available on your computer system, so the request to fetch employee details
will be done by your computer and the records will be fetched from the database by your
computer as well. This type of system is generally referred as local database system.
Single tier architecture
• Any changes or updates that are done will reflect directly to the database.
• The 1-tier architecture is used for the development of applications where a programmer
directly communicates with the database for very fast response.
 It is used for enhancement of the local application.
Example

 The three-layer solution is deployed on single tier like personal workstations.


 In the below diagram all three layers like presentation, business and data access logic are
on same machine.
Two tier architecture
Two tier architecture

 In two-tier architecture, the Database system is present at the server machine and the
DBMS application is present at the client machine, these two machines are connected with
each other through a reliable network as shown in the above diagram.
 Whenever client machine makes a request to access the database present at server using a
query language like sql, the server perform the request on the database and returns the
result back to the client.
 The application connection interface such as JDBC, ODBC(Open Database Connectivity)
are used for the interaction between server and client.
 When there are a large number of users at client side to access the database, this
architecture gives a poor performance.

 The server side is responsible for delivering the functionalities like query processing and
management of transactions.

 For example − Oracle, Sybase, Microsoft SQL Server etc.


Example

 The Tier-2 architecture of DBMS is diagrammatically represented as follows


Three tier architecture
Three tier architecture

 In three-tier architecture, another layer is present between the client machine and server
machine.
 In this architecture, the client application doesn’t communicate directly with the database
systems present at the server machine, rather the client application communicates with
server application and the server application internally communicates with the database
system present at the server.
• Mainly, the 3-tier is used for large applications on the web.
• The features of 3-tier architecture are data backup, recovery, security, and concurrency
control.
Layers

 The 3-tier architecture consists of the three layers as follows −

 This layer is also called the client layer. The front-end layer
Presentation layer −
consists of a user interface. The main purpose is to communicate with the
application layer.
 This layer is also called the business logic layer. It acts as a
Application layer −
middle layer between the client and the database server which are used to
exchange partially processed data.
 Database layer − In
this layer the data or information is stored. This layer performs
operations like insert, update and delete to connect with the database.
Example
Question

 What is TRUE about 1-tier architecture?


1. It is directly not available to the user
2. Changes are not done on the database
3. No handy tool is provided for the end user
4. It is not used for the development of local application
Answer: 

 C) No handy tool is provided for the end user


Question

 Basic client-server model is similar to –


1. 2-tier architecture
2. 3-tier architecture
3. 4-tier architecture
4. 5-tier architecture
Question

 Which API is used for the interaction in 2-tier


architecture?
1. ODBC
2. JDBC
3. Both A. and B.
4. None of the above
Question

 3-tier architecture is used in –


1. Large web application
2. Small web application
3. Both large and small web application
4. Neither small nor large web application
View of Data in DBMS

 View of data in DBMS narrate how the data is visualized at


each level of data abstraction. 
 Data abstraction allow developers to keep complex data
structures away from the users.
 The developers achieve this by hiding the complex data
structures through levels of abstraction.
Data abstraction

 Data abstraction is hiding the complex data structure in order


to simplify the user’s interface of the system. It is done
because many of the users interacting with the database
system are not that much computer trained to understand the
complex data structures of the database system.
 To achieve data abstraction, we will discuss a Three-Schema
architecture which abstracts the database at three levels
discussed below:
Three-Schema Architecture

 The main objective of this architecture is to have an effective


separation between the user interface and the physical database.
So, the user never has to be concerned regarding the internal
storage of the database and it has a simplified interaction with the
database system.
 The three-schema architecture defines the view of data at three
levels:
1. Physical level (internal level)
2. Logical level (conceptual level)
3. View level (external level)
1. Physical Level/ Internal Level

 The physical or the internal level schema describes how the


data is stored in the hardware. It also describes how the data
can be accessed.
 The physical level shows the data abstraction at the lowest
level and it has complex data structures.
 Only the database administrator operates at this level.
2. Logical Level/ Conceptual Level

 It is a level above the physical level. Here, the data is stored in


the form of the entity set, entities, their data types,
the relationship among the entity sets, user
operations performed to retrieve or modify the data and
certain constraints on the data. Well adding constraints to the
view of data adds the security. As users are restricted to
access some particular parts of the database.
 It is the developer and database administrator who operates at
the logical or the conceptual level.
3. View Level/ User level/ External level 

 It is the highest level of data abstraction and exhibits only a


part of the whole database. It exhibits the data in which the
user is interested. The view level can describe many views of
the same data.
 Here, the user retrieves the information using different
application from the database.
Three-Schema Architecture
Example

 We have to create a database of a college. Now, what entity sets would be


involved? Student, Lecturer, Department, Course and so on…
 Now, the entity sets Student, Lecturer, Department, Course will be stored in the
storage as the consecutive blocks of the memory location. This is the physical or
internal level and is hidden from the programmers but the database administrator
is it aware of it.
 At the logical level, the programmers define the entity sets and relationship among
these entity sets using a programming language like SQL. So, the programmers
work at the logical level and even the database administrator also operates at this
level.
 At the view level, the users have the set of applications which they use to retrieve
the data they are interested in.
Data Independence

 Data Independence is defined as a property of DBMS that helps


you to change the Database schema at one level of a database
system without requiring to change the schema at the next higher
level. Data independence helps you to keep data separated from
all programs that make use of it.
 You can use this stored data for computing and presentation. In
many systems, data independence is an essential function for
components of the system.
Types of Data Independence

 In DBMS there are two types of data independence


1. Physical data independence
2. Logical data independence.
Physical Data Independence

 Physical data independence defines the extent up to which the


data schema can be changed at the physical or internal level
without modifying the data schema at logical and view level.
 Well, the physical schema is changed if we add additional
storage to the system or we reorganize some files to enhance
the retrieval speed of the records.
Logical Data Independence

 Logical data independence describes the degree up to which


the logical or conceptual schema can be changed without
modifying the external schema. Now, a question arises what is
the need to change the data schema at a logical or conceptual
level?
 Well, the changes to data schema at the logical level are made
either to enlarge or reduce the database by adding or deleting
more entities, entity sets, or changing the constraints on data.
Instances and Schemas
Instance

 An instance can be defined as the information stored in the


database at a particular point of time.
 Let us discuss it with the help of an example.
 As we discussed above the database comprises of several entity sets
and the relationship between them. Now, the data in the database
keeps on changing with time. As we keep inserting or deleting the data
to and from the database.
 Now, at a particular time if we retrieve any information from the
database then that corresponds to an instance.
Schema

 The overall design of the database is called the database schema.


 Schemas are changed infrequently, if at all.
Example

 A database schema corresponds to the variable declarations (along


with associated type definitions) in a program.
 Each variable has a particular value at a given instant. The values of
the variables in a program at a point in time correspond to an
instance of a database schema.
 Database systems have several schemas, partitioned according to the levels of
abstraction. The physical schema describes the database design at the physical
level, while the logical schema describes the database design at the logical level.
 A database may also have several schemas at the view level, sometimes called
subschemas, that describe different views of the database.
 Of these, the logical schema is by far the most important, in terms of its effect on
application programs, since programmers construct applications by using the
logical schema.
 The physical schema is hidden beneath the logical schema, and can usually be
changed easily without affecting application programs.
Question

 Which Of three schemas used in three-schema model


represents how users view database?
A). Internal
B). External
C). Implementation
D). Conceptual
Question

 Which of three schemas used in three-schema model is


a complete logical View of database?
A).Conceptual
B).External
C). Internal
D). Implementation
Database Models

 A Database model defines the logical design and structure of a


database and defines how data will be stored, accessed and updated
in a database management system. While the Relational Model is
the most widely used database model, there are other models too:
• Hierarchical Model
• Network Model
• Entity-Relationship Model
• Relational Model
Hierarchical Model

 This database model organizes data into a tree-like-structure, with a


single root, to which all the other data is linked. The hierarchy starts
from the Root data, and expands like a tree, adding child nodes to
the parent nodes.
 In this model, a child node will only have a single parent node.
 This model efficiently describes many real-world relationships like
index of a book, recipes etc.
 In hierarchical model, data is organized into tree-like structure with one
one-to-many relationship between two different types of data, for
example, one department can have many courses, many professors and
of-course many students.
Network Model

 This is an extension of the Hierarchical model. In this model data is


organized more like a graph, and are allowed to have more than one
parent node.
 In this database model data is more related as more relationships are
established in this database model. Also, as the data is more related,
hence accessing the data is also easier and fast. This database model
was used to map many-to-many data relationships.
 This was the most widely used database model, before Relational
Model was introduced.
Network Model
Entity-relationship Model

 In this database model, relationships are created by dividing object of


interest into entity and its characteristics into attributes.
 Different entities are related using relationships.
 E-R Models are defined to represent the relationships into pictorial
form to make it easier for different stakeholders to understand.
 This model is good to design a database, which can then be turned
into tables in relational model(explained below).
Example

 Let's take an example, If we have to design a School Database,


then Student will be an entity with attributes name, age, address
etc. As Address is generally complex, it can be
another entity with attributes street name, pincode, city etc, and
there will be a relationship between them.
Relational Model

 In this model, data is organized in two-dimensional tables and the


relationship is maintained by storing a common field.
 This model was introduced by E.F Codd in 1970, and since then it
has been the most widely used database model, Infact, we can say
the only database model used around the world.
 The basic structure of data in the relational model is tables. All the
information related to a particular type is stored in rows of that
table.
 Hence, tables are also known as relations in relational model.
Example
Database Access Languages

 Database languages, also known as query languages or


data query languages, are a classification of programming
languages that developers use to define and access
databases, which are collections of organized data that
users can access electronically.
 These languages allow users to complete tasks such as
controlling access to data, defining and updating data and
searching for information within the database
management system (DBMS).
Categories of database languages

 Here are four types of database languages and


their uses:
 Data definition language (DDL)
 Data manipulation language (DML)
 Data control language (DCL)
 Transaction control language (TCL)
Data definition language (DDL)

 Data definition language (DDL) creates the framework of


the database by specifying the database schema, which is
the structure that represents the organization of data.
 Its common uses include the creation and alteration of
tables, files, indexes and columns within the database.
 This language also allows users to rename or drop the
existing database or its components.
List of DDL statements

• CREATE: Creates a new database or object, such as a table,


index or column
• ALTER: Changes the structure of the database or object
• DROP: Deletes the database or existing objects
• RENAME: Renames the database or existing objects
Data manipulation language (DML)

 Data manipulation language (DML) provides operations


that handle user requests, offering a way to access and
manipulate the data that users store within a database.
 Its common functions include inserting, updating and
retrieving data from the database.
List of DML statements

• INSERT: Adds new data to the existing database table


• UPDATE: Changes or updates values in the table
• DELETE: Removes records or rows from the table
• SELECT: Retrieves data from the table or multiple tables
Data control language (DCL)

 Data control language (DCL) controls access to the data


that users store within a database. Essentially, this
language controls the rights and permissions of the
database system. It allows users to grant or revoke
privileges to the database.
 Here's a list of DCL statements:
• GRANT: Gives a user access to the database
• REVOKE: Removes a user's access to the database
 Transaction control language (TCL)

 Transaction control language (TCL) manages the


transactions within a database. Transactions group a set
of related tasks into a single, executable task. All the tasks
must succeed in order for the transaction to work.
 Here's a list of TCL statements:
• COMMIT: Carries out a transaction
• ROLLBACK: Restores a transaction if any tasks fail to execute
• SAVEPOINT: Sets a point in a transaction to save
Question

 . ………………… is a full form of SQL.


A) Standard query language
B)Sequential query language
C)Structured query language
D)Server side query language
Question

 An advantage of the database management approach is


A. data is dependent on programs
B.data redundancy increases
C.data is integrated and can be accessed by multiple
programs
D.none of the above
Question

 Grant and revoke are ……. statements.


A. DDL
B.TCL
C.DCL
D.DML
ER Model
ER Model

 ER model stands for an Entity-Relationship model. It is a high-level


data model. This model is used to define the data elements and
relationship for a specified system.
 It develops a conceptual design for the database. It also develops a
very simple and easy to design view of data.
 In ER modeling, the database structure is portrayed as a diagram
called an entity-relationship diagram.
  ER model makes use of ER diagrams, which are the diagrams
sketched to design a database. ER diagrams are built on three
basic concepts: entities, attributes, and relationships between
them.
  An ER diagram defines entities, associated attributes,
and relationships between entities. This helps visualize the logical
structure of the database.
Example
For Example

 design a database for a school. In this database, a student is


an entity with attributes such as an address, name, id, age,
grades, etc.
 The address can be another entity with attributes like city, street
name, pin code, etc and there will be a relationship between
them.
Component of ER Diagram

 The ER diagram consists of three basic concepts:


 Entities
 Attributes
 Relationships
Strong
Entiry
Entity

 An entity is anything in the real world, such as an object, class,


person, or place.
 Objects that physically exist and are logically constructed in the
real world are called entities.
 Each entity consists of several characteristics or attributes that
describe that entity.
 For example, if a person is an entity, its attributes or
characteristics are age, name, height, weight, occupation,
address, hobbies, and so on.
Entity Set

  It is a group of entities of similar kinds. It can


contain entities with attributes that share similar values. It's
collectively a group of entities of a similar type.
 For example, a car entity set, an animal entity set, a bank
account entity set, and so on.
Entity types

 Entity types are the basic building blocks for describing the
structure of data. It's a category of a particular entity in
an entity set.
 In summary, an Entity is an object of a Type Entity and the set of
all entities is called an entity set.
 For Example: E1 is an entity having Entity Type Student and set of
all students is called Entity Set.
Example
Symbols Used in ER Diagrams
Types of Entities

 Entities are of two types:


 Strong Entity
 Weak Entity
Strong Entity

 A strong entity is an entity type that has a key attribute. It doesn't


depend on other entities in the schema. A strong entity always has
a primary key, and it is represented by a single rectangle in the ER
diagram.
 Example – roll_number identifies each student of the organization
uniquely and hence, we can say that the student is a
strong entity type.
Weak Entity

 Weak entity type doesn’t have a key attribute and so we cannot


uniquely identify them by their attributes alone. Therefore, a
foreign key must be used in combination with its attributes to
create a primary key. They are called Weak entity types because
they can’t be identified on their own. It relies on another
powerful entity for its unique identity.
 A weak entity is represented by a double-outlined rectangle in ER
diagrams.
Example

 The address can't be used to uniquely identify students as there


can be many students from the same locality. So, for this, we need
an attribute of Strong Entity Type i.e ‘student’ to uniquely
identify entities of Address Entity Type.
 The relationship between a weak entity type and a
strong entity type is shown with a double-outlined diamond
instead of a single-outlined diamond. 
Attributes

 Attributes are the characteristics or properties which define the entity type. In ER


diagram, the attribute is represented by an oval.
 For example, here id, Name, Age, and Mobile_No are the attributes that define
the entity type Student
 Types of Attributes

 These are the types of attributes:


 Simple attribute
 Composite attribute
 Multivalued attribute
 Derived attribute
Simple/Key Attribute

 Attributes that cannot be further decomposed into sub-attributes


are called simple attributes.
 It's an atomic value and is also known as the key attribute.
 The simple attributes are represented by an oval shape in ER
diagrams with the attribute name underlined.
Example

 As you can see from the above image, the attributes id is


represented in the shape of an ellipse along with having the
attribute name underlined.
Composite attribute

 An attribute that is composed of many other attributes and can be


decomposed into simple attributes is known as a composite
attribute. The composite attribute is represented by an ellipse.
 For example, a student's address can be divided into city, state,
country, and pin code or a full name can be divided into first
name, middle name, and last name.
Example
Multivalued attribute

 Multivalued attributes are attributes that can have more than one
value. The double oval is used to represent a multivalued
attribute.
 For example, the mobile_number of a student is a multivalued
attribute as one student can have more than one mobile number.
Derived attribute

 Derived attributes are the ones that can be derived from other
attributes of an entity type. The derived attributes are represented
by a dashed oval symbol in the ER diagram.
 For example, the age attribute can be derived from the date of
birth (DOB) attribute. So, it's a derived attribute.
Example

 The complete student (represented by the rectangle


shape) entity type is shown by the below diagram having
different attributes, where address is the composite attribute, age
is the derived attribute, phone number is the multivalued
attribute, and roll number is the key attribute.
Relationship

 The diamond shape showcases a relationship in the ER


diagram.
 It depicts the relationship between two entities.
 In the example below, both the student and the course are
entities, and study is the relationship between them. 
Example
Cardinality in DBMS

 Cardinality represents the number of times an entity of an entity set


participates in a relationship set. Or we can say that the cardinality
of a relationship is the number of tuples (rows) in a relationship.
 Types of relationships

 One-to-One Relationship
 One-to-Many Relationship
 Many-to-One Relationship
 Many-to-Many Relationship
One-to-One Relationship

 When a single element of an entity is associated with a single


element of another entity, it is called a one-to-one
relationship.
 For example, a student has only one identification card and an
identification card is given to one person.
One-to-Many Relationship

 When a single element of an entity is associated with more than one element of
another entity, it is called a one-to-many relationship
 For example, a customer can place many orders, but an order cannot be placed by
many customers.
Many-to-One Relationship

 When more than one element of an entity is related to a single element of another
entity, then it is called a many-to-one relationship.
 For example, students have to opt for a single course, but a course can have many
students.
Many-to-Many Relationship

 When more than one element of an entity is associated with more than one
element of another entity, this is called a many-to-many relationship.
 For example, you can assign an employee to many projects and a project can have
many employees.
How to Draw an ER Diagram?

 Below are some important points to draw ER diagram:


• First, identify all the Entities. Embed all the entities in a rectangle and label
them properly.
• Identify relationships between entities and connect them using a diamond in
the middle, illustrating the relationship. Do not connect relationships with each
other.
• Connect attributes for entities and label them properly.
• Eradicate any redundant entities or relationships.
• Verbs often describe relationships between entities.
• Make sure your ER Diagram supports all the data provided to design the
database.
Participation Constraints

 The participation constraint specifies the number of


instances of an entity can participate in a relationship set.
 Types of Participation Constraints:
 Total Participation
 Partial Participation
Total Participation

 The Participation of an entity set E in a relationship set R is said to be total if every entity
in E participates in at least one relationship in R.
Partial Participation

 The participation of an entity set E in relationship set R is said to be partial if only some
entities in E participate in relationships in R.
Example
DBMS Generalization

 Generalization is a process in which the common attributes of more than one


entities form a new entity. This newly formed entity is called generalized entity.
 Generalization Example
 Let say we have two entities Student and Teacher.
 Attributes of Entity Student are: Name, Address & Grade
 Attributes of Entity Teacher are: Name, Address & Salary
The ER diagram before generalization

 These two entities have two common attributes: Name and Address, we can make a
generalized entity with these common attributes.
The ER diagram after generalization
 We have created a new generalized entity Person and this entity has the common attributes
of both the entities.
 As you can see in the following ER diagram that after the generalization process the
entities Student and Teacher only has the specialized attributes Grade and Salary
respectively and their common attributes (Name & Address) are now associated with a new
entity Person which is in the relationship with both the entities (Student & Teacher).
NOTE

 Generalization uses bottom-up approach where two or more lower level entities combine
together to form a higher level new entity.
 The new generalized entity can further combine together with lower level entity to create a
further higher level generalized entity.
DBMS Specialization

 Specialization is a process in which an entity is divided into sub-entities. You can think of
it as a reverse process of generalization, in generalization two entities combine together to
form a new higher level entity. Specialization is a top-down process.
 The idea behind Specialization is to find the subsets of entities that have few distinguish
attributes.
 For example – Consider an entity employee which can be further classified as sub-entities
Technician, Engineer & Accountant because these sub entities have some distinguish attributes.
 In the above diagram, we can see that we have a higher level entity “Employee” which we
have divided in sub entities “Technician”, “Engineer” & “Accountant”. All of these are just
an employee of a company, however their role is completely different and they have few
different attributes.
 Just for the example, Here it is shown that Technician handles service requests, Engineer
works on a project and Accountant handles the credit & debit details. All of these three
employee types have few attributes common such as name & salary which we had left
associated with the parent entity “Employee” as shown in the above diagram.
DBMS Aggregation

 Aggregation is a process in which a single entity alone is not able to make sense in a
relationship so the relationship of two entities acts as one entity.
 Example:
 In real world, we know that a manager not only manages the employee working under
them but he has to manage the project as well. In such scenario if entity “Manager” makes
a “manages” relationship with either “Employee” or “Project” entity alone then it will not
make any sense because he has to manage both.
 In these cases the relationship of two entities acts as one entity.
 In our example, the relationship “Works-On” between “Employee” & “Project” acts as one
entity that has a relationship “Manages” with the entity “Manager”.
Relational Model
Relational Model

 In relational model, the data and relationships are represented by


collection of inter-related tables. Each table is a group of column and
rows, where column represents attribute of an entity and rows represents
records.
 The use of tables to store the data provided a straightforward, efficient,
and flexible way to store and access structured information. Because of
this simplicity, this data model provides easy data sorting and data access.
Hence, it is used widely around the world for data storage and processing.
Example

 Example to store the name, the CGPA attained, and the roll number of all the students of
a particular class.
Note

 A database implemented and organized in terms of the relational model is


known as a relational database management system (RDBMS). Hence,
the relational model describes how data is stored in relational databases.
 Relational Model stores the data into tables (relations).
 It makes data sorting and data access easier.
 Provides a standard way to organize data in databases.
RDBMS Concepts

 RDBMS stands for relational database management system. A relational model


can be represented as a table of rows and columns.
 A relational database has following major components:
1. Table or Relation
2. Record or Tuple
3. Field or Column name or Attribute
4. Domain
5. Instance
6. Schema
7. Keys
Table

 A table is a collection of data represented in rows and columns. Each table has a name in
database.
 For example, the following table “STUDENT” stores the information of students in
database.
 Record or Tuple:
Each row of a table is known as record. It is also known as tuple.

 Field or Column name or Attribute:


The above table “STUDENT” has three fields (or attributes): Student_Id, Student_Name,
& Student_Age.
Domain

 A domain is a set of permitted values for an attribute in table. For example, a


domain of month-of-year can accept January, February,…December as values, a
domain of dates can accept all possible valid dates etc. We specify domain of
attribute while creating a table. An attribute cannot accept values that are outside
of their domains.
 For example, In the above table “STUDENT”, the Student_Id field has integer
domain so that field cannot accept values that are not integers for example,
Student_Id cannot has values like, “First”, 10.11 etc.
Relational Schema

 It is the logical blueprint of the relation i.e., it describes the design and
the structure of the relation.

 It contains the table name, its attributes, and their types:


TABLE_NAME(ATTRIBUTE_1 TYPE_1, ATTRIBUTE_2 TYPE_2, ...)

 For our Student relation example, the relational schema will be:
STUDENT(ROLL_NUMBER INTEGER, NAME VARCHAR(20), CGPA FLOAT)
Relation Key

It is an attribute or a group of attributes that can be used to uniquely identify an


entity in a table or to determine the relationship between two tables. Relation keys
can be of 6 different types:
1) Candidate Key
2) Super Key
3) Composite Key
4) Primary Key
5) Alternate Key
6) Foreign Key

You might also like