Database Management System
Database Management System
Database is a collection of related data and data is a collection of facts and figures that can be
processed to produce information.
From <https://www.tutorialspoint.com/dbms/dbms_quick_guide.htm>
A database management system stores data in such a way that it becomes easier to
retrieve, manipulate, and produce information.
From <https://www.tutorialspoint.com/dbms/dbms_quick_guide.htm>
From <https://www.tutorialspoint.com/dbms/dbms_quick_guide.htm>
From <https://www.tutorialspoint.com/dbms/dbms_quick_guide.htm>
In 1-tier architecture, the DBMS is the only entity where the user directly sits on the DBMS and uses
it. Any changes done here will directly be done on the DBMS itself. It does not provide handy tools
for end-users. Database designers and programmers normally prefer to use single-tier architecture.
From <https://www.tutorialspoint.com/dbms/dbms_quick_guide.htm>
If the architecture of DBMS is 2-tier, then it must have an application through which the DBMS can
be accessed. Programmers use 2-tier architecture where they access the DBMS by means of an
application. Here the application tier is entirely independent of the database in terms of operation,
design, and programming.
From <https://www.tutorialspoint.com/dbms/dbms_quick_guide.htm>
3-tier Architecture
A 3-tier architecture separates its tiers from each other based on the
complexity of the users and how they use the data present in the
database. It is the most widely used architecture to design a DBMS.
• 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.
From <https://www.tutorialspoint.com/dbms/dbms_quick_guide.htm>
Data models define how the logical structure of a database is modeled. Data Models are
fundamental entities to introduce abstraction in a DBMS. Data models define how data is connected
to each other and how they are processed and stored inside the system.
From <https://www.tutorialspoint.com/dbms/dbms_data_models.htm>
Entity-Relationship Model
Entity-Relationship (ER) Model is based on the notion of real-world
entities and relationships among them. While formulating real-world
scenario into the database model, the ER Model creates entity set,
relationship set, general attributes and constraints.
ER Model is best used for the conceptual design of a database.
ER Model is based on −
• Entities and their attributes.
• Relationships among entities.
These concepts are explained below.
From <https://www.tutorialspoint.com/dbms/dbms_data_models.htm>
Relational Model
The most popular data model in DBMS is the Relational Model. It is more
scientific a model than others. This model is based on first-order predicate
logic and defines a table as an n-ary relation.
From <https://www.tutorialspoint.com/dbms/dbms_data_models.htm>
From <https://www.tutorialspoint.com/dbms/er_model_basic_concepts.htm>
A database schema is the skeleton structure that represents the logical view of the entire database.
It defines how the data is organized and how the relations among them are associated. It formulates
all the constraints that are to be applied on the data.
From <https://www.tutorialspoint.com/dbms/dbms_data_schemas.htm>
• Physical Database Schema − This schema pertains to the actual storage of
data and its form of storage like files, indices, etc. It defines how the data
will be stored in a secondary storage.
• Logical Database Schema − This schema defines all the logical constraints
that need to be applied on the data stored. It defines tables, views, and
integrity constraints.
From <https://www.tutorialspoint.com/dbms/dbms_data_schemas.htm>
From <https://www.tutorialspoint.com/dbms/dbms_data_independence.htm>
From <https://www.tutorialspoint.com/dbms/dbms_data_independence.htm>
Entity
Entities are represented by means of rectangles. Rectangles are named
with the entity set they represent.
Attributes
Attributes are the properties of entities. Attributes are represented by
means of ellipses. Every ellipse represents one attribute and is directly
connected to its entity (rectangle).
If the attributes are composite, they are further divided in a tree like
structure. Every node is then connected to its attribute. That is,
composite attributes are represented by ellipses that are connected with
an ellipse.
Explore our latest online courses and learn new skills at your own pace.
Enroll and become a certified expert to boost your career.
Relationship
Relationships are represented by diamond-shaped box. Name of the
relationship is written inside the diamond-box. All the entities (rectangles)
participating in a relationship, are connected to it by a line.
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.
• 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.
Participation Constraints
• Total Participation − Each entity is involved in the relationship. Total
participation is represented by double lines.
• Partial participation − Not all entities are involved in the relationship.
Partial participation is represented by single lines.
Generalization
As mentioned above, the process of generalizing entities, where the
generalized entities contain the properties of all the generalized entities,
is called generalization. In generalization, a number of entities are
brought together into one generalized entity based on their similar
characteristics. For example, pigeon, house sparrow, crow and dove can
all be generalized as Birds.
From <https://www.tutorialspoint.com/dbms/dbms_generalization_aggregation.htm>
Specialization
Specialization is the opposite of generalization. In specialization, a group
of entities is divided into sub-groups based on their characteristics. Take
a group ‘Person’ for example. A person has name, date of birth, gender,
etc. These properties are common in all persons, human beings. But in a
company, persons can be identified as employee, employer, customer, or
vendor, based on what role they play in the company.
From <https://www.tutorialspoint.com/dbms/dbms_generalization_aggregation.htm>
Inheritance
We use all the above features of ER-Model in order to create classes of
objects in object-oriented programming. The details of entities are
generally hidden from the user; this process known as abstraction.
Inheritance is an important feature of Generalization and Specialization. It
allows lower-level entities to inherit the attributes of higher-level entities.
From <https://www.tutorialspoint.com/dbms/dbms_generalization_aggregation.htm>
Concepts
Tables − In relational data model, relations are saved in the format of
Tables. This format stores the relation among entities. A table has rows
and columns, where rows represents records and columns represent the
attributes.
Tuple − A single row of a table, which contains a single record for that
relation is called a tuple.
Relation instance − A finite set of tuples in the relational database system
represents relation instance. Relation instances do not have duplicate
tuples.
Relation schema − A relation schema describes the relation name (table
name), attributes, and their names.
Relation key − Each row has one or more attributes, known as relation
key, which can identify the row in the relation (table) uniquely.
Attribute domain − Every attribute has some pre-defined value scope,
known as attribute domain.
From <https://www.tutorialspoint.com/dbms/relational_data_model.htm>
From <https://www.javatpoint.com/dbms-sql-command>
Relational Algebra
Relational algebra is a procedural query language. It gives a step by step process to
obtain the result of the query. It uses operators to perform queries.
Types of Relational operation
1. Select Operation:
ADVERTISEMENT
From <https://www.javatpoint.com/dbms-relational-algebra>
A large database defined as a single relation may result in data duplication. This
repetition of data may result in:
• Making relations very large.
• It isn't easy to maintain and update data as it would involve searching many
records in relation.
• Wastage and poor utilization of disk space and resources.
• The likelihood of errors and inconsistencies increases.
So to handle these problems, we should analyze and decompose the relations with
redundant data into smaller, simpler, and well-structured relations that are satisfy
desirable properties. Normalization is a process of decomposing the relations into
relations with fewer attributes.
What is Normalization?
• Normalization is the process of organizing the data in the database.
• Normalization is used to minimize the redundancy from a relation or set of
relations. It is also used to eliminate undesirable characteristics like Insertion,
Update, and Deletion Anomalies.
• Normalization divides the larger table into smaller and links them using
relationships.
• The normal form is used to reduce redundancy from the database table.
Why do we need Normalization?
The main reason for normalizing the relations is removing these anomalies. Failure
to eliminate anomalies leads to data redundancy and can cause data integrity and
other problems as the database grows. Normalization consists of a series of
guidelines that helps to guide you in creating a good database structure.
Data modification anomalies can be categorized into three types:
• Insertion Anomaly: Insertion Anomaly refers to when one cannot insert a new
tuple into a relationship due to lack of data.
• Deletion Anomaly: The delete anomaly refers to the situation where the
deletion of data results in the unintended loss of some other important data.
• Updatation Anomaly: The update anomaly is when an update of a single data
value requires multiple rows of data to be updated.
Types of Normal Forms:
Normalization works through a series of stages called Normal forms. The normal
forms apply to individual relations. The relation is said to be in particular normal form
if it satisfies constraints.
Following are the various types of Normal forms:
From <https://www.javatpoint.com/dbms-normalization>
SQL JOIN
A JOIN clause is used to combine rows from two or more tables, based on a
related column between them.
Let's look at a selection from the "Orders" table:
OrderID CustomerID OrderDate
10308 2 1996-09-18
10309 37 1996-09-19
10310 77 1996-09-20
Then, look at a selection from the "Customers" table:
CustomerID CustomerName ContactName Country
1 Alfreds Futterkiste Maria Anders Germany
2 Ana Trujillo Emparedados y helados Ana Trujillo Mexico
3 Antonio Moreno Taquería Antonio Moreno Mexico
Notice that the "CustomerID" column in the "Orders" table refers to the
"CustomerID" in the "Customers" table. The relationship between the two
tables above is the "CustomerID" column.
Then, we can create the following SQL statement (that contains an INNER
JOIN), that selects records that have matching values in both tables:
FROM Orders
Try it Yourself »
From <https://www.w3schools.com/sql/sql_join.asp>