DBMS My Notes
DBMS My Notes
2.Data models.
3.DBMS architecture.
4.Database language.
5.ER Models.
1)ER model stands for an Entity-Relationship model. It is a high-level data
model.
2)An ER model is a design or blueprint of a database. ER model are based on
the real-world entities & their relationships.
3)An ER model describe the structure of a database with help of a diagram,
which is known as entity-relationship diagram.
4)For example, suppose we design a school database. In this database, the
student will be an entity & address, name, id, age are the attributes.
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.
b. Composite Attribute:
An attribute that composed of many other attributes is known as a composite
attribute. The composite attribute is represented as ellipse.
c. Multivalued Attribute:
An attribute can have multiple 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 others attribute is known as a derived
attribute. It can be represented as dashed ellipse.
3. Relationship:
A relationship is used to describe the relation between entities. It is represent
as Diamond.
Types of relationship are as follows:
a. One-to-One Relationship:
When only one instance of an entity is associated with the relationship, then it
is known as one-to-one relationship.
For example, A female can marry to one male, and a male can marry to one
female.
AD
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 associated with the relationship then this is known as
a one-to-many relationship.
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 enrol 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.
Notation: σ p(r)
Where:
σ is used for selection prediction
r is used for relation
p is used as propositional logic formula which may use connectors like: AND OR
& NOT.
2.Projection:
o This operation shows the list of those attributes that we wish to appear
in the result. Rest of the attributes are eliminated from the table.
o It is denoted by ∏.
AD
Notation: ∏ A1, A2, An (r) Where: A1, A2, A3 is used as an attribute
name of relation r.
3. Union:
o Suppose there are two tuples R and S. The union operation contains all
the tuples that are either in R or S or both in R & S.
o It eliminates the duplicate tuples. It is denoted by ∪.
Notation: R ∪ S
Notation: R ∩ S
5. Set Difference:
o Suppose there are two tuples R and S. The set intersection operation
contains all tuples that are in R but not in S.
o It is denoted by intersection minus (-).
Notation: R - S
6. Cartesian product:
o The Cartesian product is used to combine each row in one table with
each row in the other table. It is also known as a cross product.
o It is denoted by X.
Notation: E X D
7. Rename:
The rename operation is used to rename the output relation. It is denoted
by rho (ρ).
10.File organization.
1)The file is a collection of records. Using the primary key, we can access the
records.
2)File organization is a logical relationship among various records. This method
defines how file records are mapped onto disk blocks.
3)File organization is used to describe the way in which the records are stored
in term of blocks, & blocks are placed on the storage medium.
4)Types of file organization:
Types of file organization are as follows:
12.Index structure.
1)The index is a type of data structure. It is used to locate and access the data
in a database table quickly.
2)Indexes can be created using some database columns.
o The first column of the database is the search key that contains a copy of
the primary key or candidate key of the table.
oThe second column of the database is the data reference. It contains a
set of pointers holding the address of the disk block.
3)Types of index structure:
a) Ordered indices:
The indices are usually sorted to make searching faster. The indices which are
sorted are known as ordered indices.
b) Primary Index:
o If the index is created on the basis of the primary key of the table, then it
is known as primary indexing. These primary keys are unique to each
record and contain 1:1 relation between the records.
o The primary index can be classified into two types: Dense index and
Sparse index.
c) Clustering Index:
o A clustered index can be defined as an ordered data file. Sometimes the
index is created on non-primary key columns which may not be unique
for each record.
o In this case, we will group two or more columns to get the unique value
and create index out of them. This method is called a clustering index.
d)Secondary index:
It is a two-level indexing technique used to reduce the mapping size of the
primary index.
14.ACID Properties.
1)ACID (Atomicity, Consistency, Isolation, Durability) is a set of properties of
database transaction intended to guarantee validity even in the event of
errors, power failures, etc
2)In the context of databases, a sequence of database operation that satisfies
the ACID properties & thus can be perceived as a single logical operation on
the data, is called a transaction.
3)For example, a transfer of funds from one bank account to another involves
debiting from one account & crediting to another, & this whole process is a
single transaction.
Atomicity:
All statement of a transaction must succeed completely or fail
completely in each & every situation, including power failures, errors &
crashes.
Example- Debiting & crediting in a money transfer transaction, both
must happen either together or not at all.
Consistency:
The database must remain in a consistent state after any transaction.
Data in the database should not have any changes than intended after
the transaction completion.
Isolation:
Isolation ensures that concurrent execution of transaction leaves the
database in the same state that would have been obtained if the
transactions were executed sequentially.
Durability:
Durability guarantees that once a transaction has been committed, it will
remain committed even in the case of a system failure which actually
means recording the completed transactions in non-volatile memory.
Exclusive lock(X):
Data item can be both read as well as written. This is exclusive & cannot
be held simultaneously on the same data item. X-lock is requested using
lock-X instruction.
16.Validation based protocol.
1)Validation based protocol is also called optimistic concurrency control
technique. This protocol is used in DBMS for avoiding concurrency in
transaction.
2)It is called optimistic because of the assumption it makes, i.e. very less
interference occurs, therefore, there is no need for checking while the
transaction is executed.
3)The three phases for Validation based protocol:
Read Phase:
Values of committed data items from the database can be read by a
transaction. Updates are only applied to local data versions.
Validation Phase:
Checking is performed to make sure that there is no violation of
serializability when the transaction updates are applied to the database.
Write Phase:
On the success of the validation phase, the transaction updates are
applied to the database, otherwise, the updates are discarded & the
transaction is slowed down.