Dbms 1 S
Dbms 1 S
Dbms 1 S
Unit 1
Introduction to Database System Concepts and Architecture
Data:
It is a collection of information.
The facts that can be recorded and which have implicit meaning known as 'data'.
Example: Customer ----- 1. cname.
2. cno.
3. ccity
Database:
It is a collection of interrelated data.
These can be stored in the form of tables.
A database can be of any size and varying complexity.
A database may be generated and manipulated manually or it may be computerized.
Example: Customer database consists the fields as cname, cno, and ccity
Database System:
It is computerized system, whose overall purpose is to maintain the information and to make that the
information is available on demand.
Advantages:
1. Redundancy can be reduced.
2. Inconsistency can be avoided.
3. Data can be shared.
4. Standards can be enforced.
5. Security restrictions can be applied.
6. Integrity can be maintained.
7. Data gathering can be possible.
8. Requirements can be balanced.
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 data base applications according to their requirement.
They don’t write the program code but they interact the data base by writing SQL queries
directly through the query processor.
The database approach has some very characteristic features which are discussed in detail below:
1. Structured and Described Data:
Fundamental feature of the database approach is that the database system does not only contain
the data but also the complete definition and description of these data.
These descriptions are basically details about the extent, the structure, the type and the format of
all data and, additionally, the relationship between the data. This kind of stored data is called
metadata ("data about data").
2. Separation of Data and Applications:
Application software does not need any knowledge about the physical data storage like encoding,
format, storage place, etc. It only communicates with the management system of a database
(DBMS) via a standardized interface with the help of a standardized language like SQL.
3. Data Integrity:
Data integrity is a byword for the quality and the reliability of the data of a database system.
In a broader sense data integrity includes also the protection of the database from unauthorized
access (confidentiality) and unauthorized changes. Data reflect facts of the real world.
4. Transactions:
A transaction is a bundle of actions which are done within a database to bring it from one
consistent state to a new consistent state. In between the data are inevitable inconsistent.
5. Data Persistence:
Data persistence means that in a DBMS all data is maintained as long as it is not deleted
explicitly.
The life span of data needs to be determined directly or indirectly be the user and must not be
dependent on system features.
Additionally, data once stored in a database must not be lost. Changes of a database which are
done by a transaction are persistent.
When a transaction is finished even a system crash cannot put the data in danger.
8. Simple:
o Data base management system (DBMS) gives simple and clear logical view of data. Many
operations like insertion, deletion or creation of file or data are easy to implement.
Data Models:
o Data Model gives us an idea that how the final system will look like after its complete
implementation.
o It defines the data elements and the relationships between the data elements. Data Models are
used to show how data is stored, connected, accessed and updated in the database management
system.
o Here, we use a set of symbols and text to represent the information so that members of the
organization can communicate and understand it.
o Though there are many data models being used nowadays but the Relational model is the most
widely used model.
o Apart from the Relational model, there are many other types of data models about which we
will study in details in this blog.
o Some of the Data Models in DBMS are:
1. Hierarchical Model
2. Network Model
3. Entity-Relationship Model
4. Relational Model
5. Object-Oriented Data Model
6. Object-Relational Data Model
7. Flat Data Model
8. Semi-Structured Data Model
9. Associative Data Model
10. Context Data Model
1. Hierarchical Model
Hierarchical Model was the first DBMS model. This model organizes the data in the
hierarchical tree structure.
The hierarchy starts from the root which has root data and then it expands in the form of a
tree adding child node to the parent node.
This model easily represents some of the real-world relationships like food recipes, sitemap
of a website etc.
Example: We can represent the relationship between the shoes present on a shopping website
in the following way:
3. Entity-Relationship Model
Entity-Relationship Model or simply ER Model is a high-level data model diagram.
In this model, we represent the real-world problem in the pictorial form to make it easy for the
stakeholders to understand.
It is also very easy for the developers to understand the system by just looking at the ER diagram.
We use the ER diagram as a visual tool to represent an ER Model.
ER diagram has the following three components:
Entities: Entity is a real-world thing. It can be a person, place, or even a
concept. Example: Teachers, Students, Course, Building, Department, etc are some of the entities
of a School Management System.
Attributes: An entity contains a real-world property called attribute. This is the characteristics of
that attribute. Example: The entity teacher has the property like teacher id, salary, age, etc.
Relationship: Relationship tells how two attributes are related. Example: Teacher works for a
department.
Example:
In the above diagram, the entities are Teacher and Department. The attributes of Teacher entity
are Teacher_Name, Teacher_id, Age, Salary, Mobile_Number. The attributes of
entity Department entity are Dept_id, Dept_name. The two entities are connected using the
relationship. Here, each teacher works for a department.
Features of ER Model
Graphical Representation for Better Understanding: It is very easy and simple to understand
so it can be used by the developers to communicate with the stakeholders.
ER Diagram: ER diagram is used as a visual tool for representing the model.
Database Design: This model helps the database designers to build the database and is widely
used in database design.
Advantages of ER Model
Simple: Conceptually ER Model is very easy to build. If we know the relationship between the
attributes and the entities we can easily build the ER Diagram for the model.
Effective Communication Tool: This model is used widely by the database designers for
communicating their ideas.
Easy Conversion to any Model: This model maps well to the relational model and can be easily
converted relational model by converting the ER model to the table. This model can also be
converted to any other model like network model, hierarchical model etc.
Disadvantages of ER Model
No industry standard for notation: There is no industry standard for developing an ER model.
So one developer might use notations which are not understood by other developers.
Hidden information: Some information might be lost or hidden in the ER model. As it is a high-
level view so there are chances that some details of information might be hidden.
4. Relational Model
Relational Model is the most widely used model. In this model, the data is maintained in the form
of a two-dimensional table. All the information is stored in the form of row and columns.
The basic structure of a relational model is tables. So, the tables are also called relations in the
relational model. Example: In this example, we have an Employee table.
7. Semi-Structured Model
Semi-structured model is an evolved form of the relational model.
We cannot differentiate between data and schema in this model.
Example: Web-Based data sources which we can't differentiate between the schema and data of
the website.
In this model, some entities may have missing attributes while others may have an extra attribute.
This model gives flexibility in storing the data. It also gives flexibility to the
attributes. Example: If we are storing any value in any attribute then that value can be either
atomic value or a collection of values.
Database (Data) Tier − At this tier, the database resides along with its query processing languages.
We also have the relations that define the data and their constraints at this level.
Application (Middle) Tier − At this tier reside the application server and the programs that access
the database. For a user, this application tier presents an abstracted view of the database. End-users
are unaware of any existence of the database beyond the application. At the other end, the database
tier is not aware of any other user beyond the application tier. Hence, the application layer sits in
the middle and acts as a mediator between the end-user and the database.
User (Presentation) Tier − End-users operate on this tier and they know nothing about any
existence of the database beyond this layer. At this layer, multiple views of the database can be
provided by the application. All views are generated by applications that reside in the application
tier.
Multiple-tier database architecture is highly modifiable, as almost all its components are independent and
can be changed independently.
Data Independence
A database system normally contains a lot of data in addition to users’ data. For example, it stores
data about data, known as metadata, to locate and retrieve data easily.
It is rather difficult to modify or update a set of metadata once it is stored in the database.
But as a DBMS expands, it needs to change over time to satisfy the requirements of the users. If
the entire data is dependent, it would become a tedious and highly complex job.
Metadata itself follows a layered architecture, so that when we change data at one layer, it does not
affect the data at another level. This data is independent but mapped to each other.
Database Languages:
o A DBMS has appropriate languages and interfaces to express database queries and updates.
o Database languages can be used to read, store and update the data in the database.
Types of Database Language
A database environment is a collective system of components that comprise and regulates the group
of data, management, and use of data, which consist of software, hardware, people, techniques of
handling database, and the data also.
Here, the hardware in a database environment means the computers and computer peripherals that
are being used to manage a database, and the software means the whole thing right from the operating
system (OS) to the application programs that include database management software like M.S.
Access or SQL Server. Again the people in a database environment include those people who
administrate and use the system. The techniques are the rules, concepts, and instructions given to
both the people and the software along with the data with the group of facts and information
positioned within the database environment.
Component of ER Diagram
1. Entity:
An entity may be any object, class, person or place. In the ER diagram, an entity can be represented
as rectangles.
Consider an organization as an example- manager, product, employee, department etc. can be taken
as an entity.
a. Weak Entity
An entity that depends on another entity called a weak entity. The weak entity doesn't contain any
key attribute of its own. The weak entity is represented by a double rectangle.
b. Strong Entity
A single rectangle is used for representing a strong entity set.
A diamond symbol is used for representing the relationship that exists between two strong entity
sets.
A single line is used for representing the connection of the strong entity set with the relationship
set.
A double line is used for representing the total participation of an entity set with the relationship
set.
Total participation may or may not exist in the relationship.
Example-
Consider the following ER diagram-
In this ER diagram,
Two strong entity sets “Student” and “Course” are related to each other.
Student ID and Student name are the attributes of entity set “Student”.
Student ID is the primary key using which any student can be identified uniquely.
Course ID and Course name are the attributes of entity set “Course”.
Course ID is the primary key using which any course can be identified uniquely.
Double line between Student and relationship set signifies total participation.
It suggests that each student must be enrolled in at least one course.
Single line between Course and relationship set signifies partial participation.
It suggests that there might exist some courses for which no enrollments are made.
2. Attribute
The attribute is used to describe the property of an entity. Eclipse is used to represent an attribute.
For example, id, age, contact number, name, etc. can be attributes of a student.
a. Key Attribute
The key attribute is used to represent the main characteristics of an entity. It represents a primary
key. The key attribute is represented by an ellipse with the text underlined.
b. Composite Attribute
An attribute that composed of many other attributes is known as a composite attribute. The
composite attribute is represented by an ellipse, and those ellipses are connected with an ellipse.
c. Multivalued Attribute
An attribute can have more than one value. These attributes are known as a multivalued attribute. The double
oval is used to represent multivalued attribute.
For example, a student can have more than one phone number.
d. Derived Attribute
An attribute that can be derived from other attribute is known as a derived attribute. It can be
represented by a dashed ellipse.
For example, A person's age changes over time and can be derived from another attribute like Date of birth.
3. Relationship
A relationship is used to describe the relation between entities. Diamond or rhombus is used to
represent the relationship.
b. One-to-many relationship
When only one instance of the entity on the left, and more than one instance of an entity on the right
associates with the relationship then this is known as a one-to-many relationship.
For example, Scientist can invent many inventions, but the invention is done by the only specific
scientist.
c. Many-to-one relationship
When more than one instance of the entity on the left, and only one instance of an entity on the right
associates with the relationship then it is known as a many-to-one relationship.
For example, Student enrolls for only one course, but a course can have many students.
d. Many-to-many relationship
When more than one instance of the entity on the left, and more than one instance of an entity on the
right associates with the relationship then it is known as a many-to-many relationship.
For example, Employee can assign by many projects and project can have many employees.
Relationship Set-
A relationship set is a set of relationships of same type.
Example-
Set representation of above ER diagram is-
There are numbers (represented by M and N) written above the lines which connect relationships and
entities. These are called cardinality ratios. These represent the maximum number of entities that can be
associated with each other through relationship, R.
Types of Cardinality :
There can be 4 types of cardinality –
1. One-to-one (1:1) –
When one entity in each entity set takes part at most once in the relationship, the cardinality is one -
to-one.
2. One-to-many (1: N) –
If entities in the first entity set take part in the relationship set at most once and entities in the second
entity set take part many times (at least twice), the cardinality is said to be one-to-many.
3. Many-to-one (N:1) –
If entities in the first entity set take part in the relationship set many times (at l east twice), while
entities in the second entity set take part at most once, the cardinality is said to be many-to-one.
4. Many-to-many (N: N) –
The cardinality is said to be many to many if entities in both the entity sets take part many times (at
least twice) in the relationship set.
Participation Constraints:
Participation Constraints tell us that that the participation in a relationship can either be total or
partial.
When each entity in an entity set participates in a relation, it is called Total Participation.
However, when all entities in the given entity set do not participate in a relation, it is called Partial
Participation.
Structural Constraints:
Structural Constraints are also called Structural properties of a database management
system (DBMS).
Cardinality Ratios and Participation Constraints taken together are called Structural
Constraints. The name constraints refer to the fact that such limitations must be imposed
on the data, for the DBMS system to be consistent with the requirements.
ER Diagram
An Entity–relationship model (ER model) describes the structure of a database with the
help of a diagram, which is known as Entity Relationship Diagram (ER Diagram).
An ER model is a design or blueprint of a database that can later be implemented as a
database. The main components of E-R model are: entity set and relationship set.
An ER diagram shows the relationship among entity sets. An entity set is a group of similar
entities and these entities can have attributes.
In terms of DBMS, an entity is a table or attribute of a table in database, so by showing
relationship among tables and their attributes, ER diagram shows the complete logical
structure of a database.
A simple ER Diagram:
In the following diagram we have two entities Student and College and their relationship.
The relationship between Student and College is many to one as a college can have many
students however a student cannot study in multiple colleges at the same time.
Student entity has attributes such as Stu_Id, Stu_Name & Stu_Addr and College entity has
attributes such as Col_ID & Col_Name.
Here are the geometric shapes and their meaning in an E-R Diagram.
Rectangle: Represents Entity sets.
Ellipses: Attributes
Diamonds: Relationship Set
Lines: They link attributes to Entity Sets and Entity sets to Relationship Set
Double Ellipses: Multivalued Attributes
Dashed Ellipses: Derived Attributes
Double Rectangles: Weak Entity Sets
Double Lines: Total participation of an entity in a relationship set