6. Concept of Data,Database,DBMS
PCP,NIGDI, Mrs.S.S.Jogdand 6
Definition
•Data is nothing but facts and figures that can be recorded in system and have
some special meaning assigned to it.
•In the context of computer science, it refers to information that has been
translated into a form that is efficient for movement or processing.
•For example- name, age, address, account _no. etc,
•A Database is a collection of information or facts that is organized so that it
can be easily processed, managed, controlled, accessed or updated.
•In a banking application, data is the whole collection of bank account numbers;
bank customers’names, addresses, and ages; bank transactions and so on.
•Data in database can be added, updated, modified, expanded and deleted.
7. or information relevant to an any
7
•Definition:-
Database: The collection of interrelated data
enterprise is called as Database .
Database Management System (DBMS) is a collection of interrelated data and set
of programs to access those data. DBMS provides a way to store and retrieve database
information that is both convenient and efficient.
•It allowing users to store, process and analyze data easily. DBMS also provides
protection and security to the databases. It also maintains data consistency in case of
multiple users.
•DBMS provides us with an interface or a tool, to perform various operations like creating
database, storing data in it, updating data, creating tables in the database and a lot more.
•Here are some examples of popular DBMS used these days:
MySQL
Oracle
IBM DB2
PostgreSQL
MongoDB
Hadoop
Amazon SimpleDB (cloud based) etc.
8. File Processing System
8
•File processing system is a computer based
system in which all the information is stored in
various computer files.
•Initially file processing system was useful but as
the requirement of data processing and the size of
data increases,the drawback of the system comes
into picture.
9. Disadvantage of File System
9
• Data Redundancy
• Data Inconsistency
• Limited Concurrency
• Problem of Data Security
• Poor Security
10. Advantages of DBMS over file System –
10
•To provide data sharing
•Reduction of Data Redundancy
•Avoiding Inconsistency
•Transactional Support
•Maintaining Integrity
•Enforcement of Security
11. Applications of Database
11
• Railway Reservation System
•Hospital Management System
•Library Management System
•Banking
•Universities and Colleges
•Online Shoppings
•Human Resource Management
12. 1.2 Three Levels Of Database Architecture/ Three levels of
data abstraction
Three levels of DBMS
architecture:-
1.Physical Level / Internal
Schema/Internal View
2.Logical Level / Conceptual
Schema/ logical view
3.External Level / External
Schema/ External view
12
13. •1. Physical Level
•Physical level describes the physical storage structure of data in database.
•It is also known as Internal Level.
•This level is very close to physical storage of data.
•At lowest level, data is stored in the form of bits with the physical addresses on
the secondary storage device.
•At highest level, it can be viewed in the form of files.
•The internal schema defines the various stored data types. It uses a physical data
model.
13
14. •2. Conceptual Level
•Conceptual level describes the structure of the whole database for a group of
users.
•It is also called as the data model.
•Conceptual schema is a representation of the entire content of the database.
•These schema contains all the information to build relevant external records.
•It hides the internal details of physical storage.
14
•3. External Level
•External level is related to the data which is viewed by individual end users.
•This level includes a no. of user views or external schema.
•This level is closest to the user.
•External view describes the segment of the database that is required for a
particular user group and hides the rest of the database from that user group.
15. 1.3 Data Abstraction
•Database systems are made-up of complex data structures. To ease the user
interaction with database, the developers hide internal irrelevant details
from users. This process of hiding irrelevant details from user is called data
abstraction.
15
16. Three levels of Data Abstraction:
16
•Physical level: This is the lowest level of data abstraction. It describes how
data is actually stored in database. You can get the complex data structure
details at this level.
•Logical level: This is the middle level of 3-level data abstraction architecture.
It describes what data is stored in database.
•At view level, user just interact with system with the help of GUI and enter the
details at the screen, they are not aware of how the data is stored and what
data is stored; such details are hidden from them.
17. Instance and Schema in DBMS
17
•Definition of schema: Design of a database is called the schema. Schema can
be changed infrequently as information is inserted and deleted.
•Database system have three types of schema - Physical schema, logical
schema and view schema.
•The design of a database at physical level is called physical schema, how the
data stored in blocks of storage is described at this level.
•Design of database at logical level is called logical schema, programmers and
database administrators work at this level, at this level data can be described as
certain types of data records gets stored in data structures, however the internal
details such as implementation of data structure is hidden at this level
(available at physical level).
•Design of database at view level is called view schema. This generally
describes end user interaction with database systems.
18. •Definition of instance: The data stored in database at a particular
moment of time is called instance of database.
•Database schema defines the variable declarations in tables that
belong to a particular database; the value of these variables at a
moment of time is called the instance of that database.
18
19. Data Independence
•Definition-The ability to modify a schema definition in one level without
affecting a schema definition in a higher level is called Data Independence.
•Types of Data Independence:
1) Physical data independence
•The ability to modify the physical schema without causing application
programs to be rewritten
•Modifications at this level are usually to improve performance
2) Logical data independence
•The ability to modify the conceptual schema without causing application
programs to be rewritten
•Usually done when logical structure of database is altered
•Logical data independence is harder to achieve as the application programs
are usually heavily dependent on the logical structure of the data. An analogy
is made to abstract data types in program
19
ming languages.
21. Components of DBMS are broadly classified as follows :
1.Users:
(a)Naïve User
(b)Application User
(c)Sophisticated User
(d)Database Administrator
2. Query Processor :
(a) DML Compiler
(b) Embedded DML pre-compiler
(c) DDL Interpreter
(d) Query Evaluation Engine
3. Storage Manager :
(a) Authorization and Integrity Manager
(b) Transaction Manager
(c) File Manager
(d) Buffer Manager
4. Data Structure :
(a) Data Files
(b) Data Dictionary
(c) Indices
(d) Statistical Data
21
22. 1. Query Processor Components :
•DML Pre-compiler : It translates DML statements in a query
language into low level instructions that query evaluation engine
understands. It also attempts to transform user's request into an
equivalent but more efficient form.
•Embedded DML Pre-compiler : It converts DML statements
embedded in an application program to normal procedure calls in
the host language. The Pre-compiler must interact with the DML
compiler to generate the appropriate code.
•DDL Interpreter : It interprets the DDL statements and records
them in a set of tables containing meta data or data dictionary.
•Query Evaluation Engine : It executes low-level instructions
generated by the DML compiler.
22
23. 2. Storage Manager Components :
They provide the interface between the low-level data stored in the database and
application programs and queries submitted to the system.
•Authorization and Integrity Manager : It tests for the satisfaction of integrity
constraints checks the authority of users to access data.
•Transaction Manager : It ensures that the database remains in a consistent state
despite the system failures and that concurrent transaction execution proceeds
without conflicting.
•File Manager : It manages the allocation of space on disk storage and the data
structures used to represent information stored on disk.
•Buffer Manager : It is responsible for fetching data from disk storage into main
memory and deciding what data to cache in memory.
3. Data Structures :
Following data structures are required as a part of the physical system
implementation.
• Data Files : It stores the database.
•Data Dictionary : It stores meta data (data about data) about the structure of
the database.
• Indices : Provide fast access to data items that hold particular values.
• Statistical Data : It stores statistical information about the data in the database.
23
This information is used by query processor to select efficient ways to execute
24. Data Models in DBMS
A Data Model is a logical structure of Database. It describes the design of
database to reflect entities, attributes, relationship among data, constrains etc.
Types of Data Models:
a) Object based logical Models – Describe data at the conceptual and view
levels.
•E-R Model
•Object oriented Model
b) Record based logical Models – Like Object based model, they also
describe data at the conceptual and view levels. These models specify
logical structure of database with records, fields and attributes.
•Relational Model
•Hierarchical Model
•Network Model
c) Physical Data Models – These models describe data at the lowest level of
abstraction. 24
25. Hierarchical model
•A hierarchical data model is a data model which the data is
organized into a tree like structure.
•The structure allows repeating information using parent/child
relationships: each parent can have many children but each child
only has one parent. All attributes of a specific record are listed
under an entity type
•This model was primarily used by IBM’s Information
Management Systems in the 60s and 70s, but they are rarely seen
today due to certain operational inefficiencies.
Fig: Hierarchical Da
2t
5
a model
26. Network model
•The network model builds on the hierarchical model by allowing
multiple
many-to-many relationships between linked records, implying
parent records.
•Based on mathematical set theory, the model is constructed with sets of
related records. Each set consists of one owner or parent record and one or
more member or child records. A record can be a member or child in multiple
sets, allowing this model to convey complex relationships.
•It was most popular in the 70s after it was formally defined by the Conference
on Data Systems Languages (CODASYL).
26
Fig: Network Data Model
27. Relational Data Model
27
•The most common model, the relational model sorts data into tables, also
known as relations, each of which consists of columns and rows. Each
column lists an attribute of the entity in question, such as price, zip code, or
birth date. Together, the attributes in a relation are called a domain. A
particular attribute or combination of attributes is chosen as a primary key that
can be referred to in other tables, when it’s called a foreign key.
•Each row, also called a tuple, includes data about a specific instance of the
entity in question, such as a particular employee.
•The model also accounts for the types of relationships between those tables,
including one-to-one, one-to-many, and many-to-many relationships.
• Relational databases are typically written in Structured Query Language
(SQL). The model was introduced by E.F. Codd in 1970.
29. 1.6 Data Modelling Using E-R model
29
•E-R Model-An entity relationship model, also called an
Entity-Relationship Diagram (ERD), is a graphical representation of
entities and their relationships to each other.
•An entity is a piece of data - an “object” or a “thing” in real world that
is distinguishable from other objects.
•ERD can express the overall logical structure of database graphically.
•Following are the terminologies and notations used in ERD.
30. Entity
30
•An entity can be a real-world object, either animate or
inanimate, that can be easily identifiable.
•For example, in a school database, students, teachers, classes,
and courses offered can be considered as entities. All these
entities have some attributes or properties that give them their
identity.
•An entity set is a collection of similar types of entities. An entity
set may contain entities with attribute sharing similar values.
•For example, a Students set may contain all the students of a
school; likewise a Teachers set may contain all the teachers of a
school from all faculties. Entity sets need not be disjoint.
32. Strong Entity
32
•Strong Entity:-The Strong Entity is the one whose existence does not
depend on the existence of any other entity in a schema.
•It is denoted by a single rectangle.
•A strong entity always has the primary key in the set of attributes
that describes the strong entity.
•It indicates that each entity in a strong entity set can be uniquely
identified.
•Set of similar types of strong entities together forms the Strong Entity
Set. A strong entity holds the relationship with the weak entity via an
Identifying Relationship, which is denoted by double diamond in the
ER diagram. On the other hands, the relationship between two strong
entities is denoted by a single diamond and it is simply called as a
relationship.
33. •Let us understand this concept with the help of an example; a
customer borrows a loan. Here we have two entities first a customer
entity, and second a loan entity.
Fig: ERD
33
34. Weak entity
PCP,NIGDI, Mrs.S.S.Jogdand 34
• Weak entity is the one that depends on its owner entity ( i.e. a strong
entity) for its existence.
• An entity that does not have a primary key is referred to as a weak entity .
• A weak entity is denoted by the double rectangle.
• Weak entity do not have the primary key instead it has a partial key.
•Partial Key: Specifies a key that is only partially unique. Used for weak
entities that uniquely discriminates the weak entities.
•The collection of similar weak entities is called Weak Entity Set. The
relationship between a weak entity and a strong entity is always denoted with
an Identifying Relationship i.e. double diamond.
35. Comparison
ASIS FOR COMPARISON STRONG ENTITY WEAK ENTITY
Basic The Strong entity has a
primary key
The weak entity has a
partial discriminator key.
Depends The Strong entity is
independent of any other
entity in a schema.
Weak entity depends on
the strong entity for its
existence.
Denoted
Relation
Strong entity is denoted by
a single rectangle.
The relation between two
strong entities is denoted
by a single diamond simply
called relationship.
Weak entity is denoted with
the double rectangle.
The relationship between a
weak and a strong entity is
denoted by Identifying
Relationship denoted with
double diamond.
Participation Weak entity always has
total participation in the
identifying relationship
Strong entity may or may
not have total p3a5rticipation
in the relationship.
36. Components of an E-R diagram
•Entity:- Any real-world object can be represented as an entity
about which data can be stored in a database. All the real world
objects like a book, an organization, a product, a car, a person are
the examples of an entity. Any living or non-living objects can be
represented by an entity. An entity is symbolically represented by
a rectangle enclosing its name.
Entity
36
37. Entities can be characterized into two types:
•Strong entity: A strong entity has a primary key attribute which
uniquely identifies each entity. Symbol of strong entity is same as
an entity.
Strong Entity
Weak entity: A weak entity does not have a primary key
attribute and depends on other entity via a foreign key attribute.
37
38. Attributes
•Entities are represented by means of their properties, called attributes. All
attributes have values. For example, a Car entity may have color, price, and
registration no., model no. as attributes.
•There exists a domain or range of values that can be assigned to attributes. For
example, a car name cannot be a numeric value. It has to be alphabetic. A s car
registration nocannot be negative, etc.
Types of Attributes
Simple attribute − Simple attributes are atomic values, which cannot be
divided further. For example, a student's phone number is an atomic value of
10 digits.
PCP,NIGDI, Mrs.S.S.Jogdand 38
39. •Composite attribute − Composite attributes
are made of more than one simple attribute.
• For example, a student's complete name may
have first_name and last_name.
•Derived attribute − Derived attributes are the attributes that do not exist in
the physical database, but their values are derived from other attributes present
in the database. For example, average_salary in a department should not be
saved directly in the database, instead it can be derived. For another example,
age can be derived from data_of_birth.
39
40. •Single-value attribute − Single-value attributes contain single value. For
example − Social_Security_Number.
•Multi-value attribute − Multi-value attributes may contain more than one
values. For example, a person can have more than one phone number,
email_address, etc.
40
41. * Entity-Set and Keys:
•Key: Key is an attribute or collection of attributes that uniquely
identifies an entity among entity set.
For example, the roll_number of a student makes him/her identifiable
among students.
•Super Key − A set of attributes (one or more) that collectively
identifies an entity in an entity set.
•Candidate Key − A minimal super key is called a candidate key. An
entity set may have more than one candidate key.
•Primary Key − A primary key is one of the candidate keys chosen by
the database designer to uniquely identify the entity set.
41
42. Relationship: The association among entities is called a relationship.
For example,
an employee works_at a department,
a student enrolls in a course.
An employee assigned a project.
Teacher teaches a student.
Author writes a book.
A diamond is used to symbolically represent a relationship in the E-R diagram.
Relationship Set
A set of relationships of similar type is called a relationship set. Like entities, a relationship
too can have attributes. These attributes are called descriptive attributes.
Degree of Relationship
The number of participating entities in a relationship defines the degree of the relationship.
Binary = degree 2 Ternary = degree 3 n-ary = degree
* Relationship
42
44. * Mapping Cardinalities
Cardinality defines the number of entities in one entity set, which can be associated
with the number of entities of other set via relationship set.
One-to-one − One entity from entity set A can be associated with at most one entity
of entity set B and vice versa.
44
45. One-to-many − One entity from entity set A can be associated with more than one entities of entity set B
however an entity from entity set B, can be associated with at most one entity.
Many-to-one − More than one entities from entity set A can be associated with
at most one entity of entity set B, however an entity from entity set B can be
associated with more than one entity from entity set A
45
46. Many-to-many − One entity from A can be associated with more than
one entity from B and vice versa.
PCP,NIGDI, Mrs.S.S.Jogdand 46
47. •Binary Relationship and Cardinality
-A relationship where two entities are participating is called a binary relationship.
Cardinality is the number of instance of an entity from a relation that can be
associated with the relation.
1.One-to-one − When only one instance of an entity is associated with the
relationship, it is marked as '1:1'. The following image reflects that only one
instance of each entity should be associated with the relationship. It depicts
one-to-one relationship.
2. One-to-many − When more than one instance of an entity is associated with a
relationship, it is marked as '1:N'. The following image reflects that only one instance of
entity on the left and more than one instance of an entity on the right can be associated with
the relationship. It depicts one-to-many relationship.
47
48. Many-to-one − When more than one instance of entity is associated with the
relationship, it is marked as 'N:1'. The following image reflects that more than one
instance of an entity on the left and only one instance of an entity on the right can be
associated with the relationship. It depicts many-to-one relationship.
Many-to-many − The following image reflects that more than one instance of an
entity on the left and more than one instance of an entity on the right can be
associated with the relationship. It depicts many-to-many relationship
48
49. E-R diagram for library management system
PCP,NIGDI, Mrs.S.S.Jogdand 49