DBMS Notes For B.TECH
DBMS Notes For B.TECH
There are the following differences between DBMS and File systems:
Data DBMS gives an abstract view of The file system provides the
Abstraction data that hides the details. detail of the data
representation and storage of
data.
The Conceptual/ Internal Mapping lies between the conceptual level and the
internal level. Its role is to define the correspondence between the records
and fields of the conceptual level and files and data structures of the internal
level.
The external/Conceptual Mapping lies between the external level and the
Conceptual level. Its role is to define the correspondence between a
particular external and the conceptual view.
There are the following operations which have the authorization of Revoke:
There are the following operations which have the authorization of Revoke:
CONNECT, INSERT, USAGE, EXECUTE, DELETE, UPDATE and SELECT.
There are different types of Database models and each one has its own
set of features.
You can define how you want to structure the application data using a
database model.
In this tutorial you will learn about the 7 database model that are popularly
used.
There are several different Database model types, some of them are old,
while some of them are new, to cater to the new age requirements. Here is a
list of the 7 popular Database models:
1. Hierarchical Model
2. Network Model
3. Entity-relationship Model
4. Relational Model
5. Object-oriented Model
6. NoSQL Model
7. Graph Model
Let's learn about the different types of database models along with their
main features and when should you use them.
1. Hierarchical Model
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.
Here are a few points to mark the advantages and disadvantages of the
Hierarchical database model:
2. Network Model
This was the most widely used database model before Relational Model
was introduced.
You may want to explore this if you are developing some social
networking applications, although the Graph Database model is new
and is far better than the Network Database model.
3. Entity-relationship Model
This model is good to design a database, which can then be turned into
tables in a relational model (explained below).
1. Entity:
An entity may be any object, class, person or place. In the ER diagram, an
entity can be represented as rectangles.
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.
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.
Key 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.
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.
4. Relational Model
This model was introduced by E.F Codd in 1970, and since then it has
been the most widely used database model.
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.
3. It supports SQL using which you can easily query the data.
In the above figure, Electronics is the root node which has two children
i.e. Televisions and Portable Electronics. These two has further children
for which they act as parent. For example: Television has children as
Tube, LCD and Plasma, for these three Television act as parent. It
follows one to many relationship.
2. Network Data Model:
It is the advance version of the hierarchical data model. To organize
data it uses directed graphs instead of the tree-structure. In this child
can have more than one parent. It uses the concept of the two data
structures i.e. Records and Sets.
In the above figure, Project is the root node which has two children i.e.
Project 1 and Project 2. Project 1 has 3 children and Project 2 has 2
children. Total there are 5 children i.e Department A, Department B
and Department C, they are network related children as we said that
this model can have more than one parent. So, for the Department B
and Department C have two parents i.e. Project 1 and Project 2.
Difference between Hierarchical Data Model and Network Data
Model :
S.
No. Hierarchical Data Model Network Data Model
parent node.
It is used to access the data which is complex It is used to access the data which
7.
and asymmetric. is complex and symmetric.
Types of keys
1. Domain constraints
o Domain constraints can be defined as the definition of a valid set of values
for an attribute.
o The data type of domain includes string, character, integer, time, date,
currency, etc. The value of the attribute must be available in the
corresponding domain.
Example:
Example:
3. Referential Integrity Constraints
o A referential integrity constraint is specified between two tables.
o In the Referential integrity constraints, if a foreign key in Table 1 refers to the
Primary Key of Table 2, then every value of the Foreign Key in Table 1 must
be null or be available in Table 2.
Example:
4. Key constraints
o Keys are the entity set that is used to identify an entity within its entity set
uniquely.
o An entity set can have multiple keys, but out of which one key will be the
primary key. A primary key can contain a unique and null value in the
relational table.
Example:
Unit-2
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.
1. Select Operation:
o The select operation selects tuples that satisfy a given predicate.
o It is denoted by sigma (σ).
1. Notation: σ p(r)
Where:
Input:
1. σ BRANCH_NAME="perryride" (LOAN)
Output:
BRANCH_NAME LOAN_NO AMOUNT
2. Project Operation:
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 ∏.
Where
Output:
NAME CITY
Jones Harrison
Smith Rye
Hays Harrison
Curry Rye
Johnson Brooklyn
Brooks Brooklyn
3. Union Operation:
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 ∪.
1. Notation: R ∪ S
Example:
DEPOSITOR RELATION
CUSTOMER_NAME ACCOUNT_NO
Johnson A-101
Smith A-121
Mayes A-321
Turner A-176
Johnson A-273
Jones A-472
Lindsay A-284
BORROW RELATION
CUSTOMER_NAME LOAN_NO
Jones L-17
Smith L-23
Hayes L-15
Jackson L-14
Curry L-93
Smith L-11
Williams L-17
Input:
1. ∏ CUSTOMER_NAME (BORROW) ∪ ∏ CUSTOMER_NAME (DEPOSITOR)
Output:
CUSTOMER_NAME
Johnson
Smith
Hayes
Turner
Jones
Lindsay
Jackson
Curry
Williams
Mayes
4. Set Intersection:
o Suppose there are two tuples R and S. The set intersection operation contains
all tuples that are in both R & S.
o It is denoted by intersection ∩.
1. Notation: R ∩ S
Input:
1. ∏ CUSTOMER_NAME (BORROW) ∩ ∏ CUSTOMER_NAME (DEPOSITOR)
Output:
CUSTOMER_NAME
Smith
Jones
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 (-).
1. Notation: R - S
Input:
Output:
CUSTOMER_NAME
Jackson
Hayes
Willians
Curry
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.
1. Notation: E X D
Example:
EMPLOYEE
1 Smith A
2 Harry C
3 John B
DEPARTMENT
DEPT_NO DEPT_NAME
A Marketing
B Sales
C Legal
Input:
1. EMPLOYEE X DEPARTMENT
Output:
EMP_ID EMP_NAME EMP_DEPT DEPT_NO DEPT_NAME
1 Smith A A Marketing
1 Smith A B Sales
1 Smith A C Legal
2 Harry C A Marketing
2 Harry C B Sales
2 Harry C C Legal
3 John B A Marketing
3 John B B Sales
3 John B C Legal
7. Rename Operation:
The rename operation is used to rename the output relation. It is denoted
by rho (ρ).
1. ρ(STUDENT1, STUDENT)
Introduction
Relational Calculus in database management system (DBMS) is all about "What you want ?".
Relational calculus does not tell us how to get the results from the Database, but it just cares
about what we want.
The theory of Relational calculus was introduced by computer scientist and
mathematician Edgar Codd. Let's deep dive and try to understand Relational calculus.
1. Procedural Language - Those Languages which clearly define how to get the required results
from the Database are called Procedural Language. Relational algebra is a Procedural Language.
2. Declarative Language - Those Language that only cares about What to get from the database
without getting into how to get the results are called Declarative Language. Relational
Calculus is a Declarative Language.
So Relational Calculus is a Declarative Language that uses Predicate Logic or First-Order Logic
to determine the results from Database.
Tuple Relational Calculus in DBMS uses a tuple variable (t) that goes to each row of the table
and checks if the predicate is true or false for the given row. Depending on the given predicate
condition, it returns the row or part of the row.
{t \| P(t)}
Where t is the tuple variable that runs over every Row, and P(t) is the predicate logic expression
or condition.
Let's take an example of a Customer Database and try to see how TRC expressions work.
Customer Table
Customer_id Name Zip code
1 Rohit 12345
2 Rahul 13245
Customer_id Name Zip code
3 Rohit 56789
4 Amit 12345.
Example 1: Write a TRC query to get all the data of customers whose zip code is 12345.
Workflow of query - The tuple variable "t" will go through every tuple of the Customer table.
Each row will check whether the Cust_Zipcode is 12345 or not and only return those rows that
satisfies the Predicate expression condition.
The TRC expression above can be read as "Return all the tuple which belongs to the
Customer Table and whose Zipcode is equal to 12345."
1 Rohit 12345
4. Amit 12345
Example 2: Write a TRC query to get the customer id of all the Customers.
Customer_id
4
Domain Relational Calculus (DRC)
Domain Relational Calculus uses domain Variables to get the column values required from the
database based on the predicate expression or condition.
{<x1,x2,x3,x4...> \| P(x1,x2,x3,x4...)}
where,
<x1,x2,x3,x4...> are domain variables used to get the column values required,
and P(x1,x2,x3...) is predicate expression or condition.
Let's take the example of Customer Database and try to understand DRC queries with some
examples.
Customer Table
Customer_id Name Zip code
1 Rohit 12345
2 Rahul 13245
3 Rohit 56789
4 Amit 12345
Example 1: Write a DRC query to get the data of all customers with Zip code 12345.
Workflow of Query: In the above query x1,x2,x3 (ordered) refers to the attribute or column
which we need in the result, and the predicate condition is that the first two domain variables x1
and x2 should be present while matching the condition for each row and the third domain
variable x3 should be equal to 12345.
1 Rohit 12345
4 Amit 12345
Example 2: Write a DRC query to get the customer id of all the customer.
DRC Query: { <x1> \| ∃ x2,x3(<x1,x2,x3> ∈ Customer ) }
Customer_id
42 abc CO A4
43 pqr IT A3
nam
roll_no e dept_name dept_building
44 xyz CO A4
45 xyz IT A3
46 mno EC B2
47 jkl ME B2
42 abc 17
43 pqr 18
44 xyz 18
42 abc 17
43 pqr 18
44 xyz 18
42 abc 17
43 pqr 18
44 xyz 18
roll_no name age
45 abc 19
42 abc CO 4
43 pqr EC 2
44 xyz IT 1
45 abc EC 2
1. Data Normalization
2. Query Optimization
3. Consistency of Data
SQL JOIN
As the name shows, JOIN means to combine something. In case of SQL, JOIN
means "to combine two or more tables".
In SQL, JOIN clause is used to combine the records from two or more tables
in a database.
Sample Table
EMPLOYEE
101 1 Testing
102 2 Development
103 3 Designing
104 4 Development
1. INNER JOIN
In SQL, INNER JOIN selects records that have matching values in both tables
as long as the condition is satisfied. It returns the combination of all rows
from both the tables where the condition satisfies.
Syntax
Query
Output
EMP_NAME DEPARTMENT
Angelina Testing
Robert Development
Christian Designing
Kristen Development
2. LEFT JOIN
The SQL left join returns all the values from left table and the matching
values from the right table. If there is no matching join value, it will return
NULL.
Syntax
Query
Output
EMP_NAME DEPARTMENT
Angelina Testing
Robert Development
Christian Designing
Kristen Development
Russell NULL
Marry NULL
3. RIGHT JOIN
In SQL, RIGHT JOIN returns all the values from the values from the rows of
right table and the matched values from the left table. If there is no
matching in both tables, it will return NULL.
Syntax
Query
Output
EMP_NAME DEPARTMENT
Angelina Testing
Robert Development
Christian Designing
Kristen Development
4. FULL JOIN
In SQL, FULL JOIN is the result of a combination of both left and right outer
join. Join tables have all the records from both tables. It puts NULL on the
place of matches not found.
Syntax
1. SELECT table1.column1, table1.column2, table2.column1,....
2. FROM table1
3. FULL JOIN table2
4. ON table1.matching_column = table2.matching_column;
Query
Output
EMP_NAME DEPARTMENT
Angelina Testing
Robert Development
Christian Designing
Kristen Development
Russell NULL
Marry NULL
Example 2 –
ID Name Courses
------------------
1 A c1, c2
2 E c3
3 M C2, c3
In the above table Course is a multi-valued attribute so it is
not in 1NF. Below Table is in 1NF as there is no multi-valued
attribute
ID Name Course
------------------
1 A c1
1 A c2
2 E c3
3 M c2
3 M c3
Second Normal Form
To be in second normal form, a relation must be in first normal form
and relation must not contain any partial dependency. A relation is in
2NF if it has No Partial Dependency, i.e., no non-prime attribute
(attributes which are not part of any candidate key) is dependent on
any proper subset of any candidate key of the table. Partial
Dependency – If the proper subset of candidate key determines non-
prime attribute, it is called partial dependency.
Example 1 – Consider table-3 as following below.
STUD_NO COURSE_NO COURSE_FEE
1 C1 1000
2 C2 1500
1 C4 2000
4 C3 1000
4 C1 1000
2 C5 2000
{Note that, there are many courses having the same course
fee} Here, COURSE_FEE cannot alone decide the value of
COURSE_NO or STUD_NO; COURSE_FEE together with
STUD_NO cannot decide the value of COURSE_NO;
COURSE_FEE together with COURSE_NO cannot decide the
value of STUD_NO; Hence, COURSE_FEE would be a non-prime
attribute, as it does not belong to the one only candidate key
{STUD_NO, COURSE_NO} ; But, COURSE_NO -> COURSE_FEE,
i.e., COURSE_FEE is dependent on COURSE_NO, which is a
proper subset of the candidate key. Non-prime attribute
COURSE_FEE is dependent on a proper subset of the
candidate key, which is a partial dependency and so this
relation is not in 2NF. To convert the above relation to 2NF,
we need to split the table into two tables such as : Table 1:
STUD_NO, COURSE_NO Table 2: COURSE_NO, COURSE_FEE
Table 1
Table 2
STUD_NO COURSE_NO COURSE_NO
COURSE_FEE
1 C1 C1
1000
2 C2 C2
1500
1 C4 C3
1000
4 C3 C4
2000
4 C1 C5
2000
NOTE: 2NF tries to reduce the redundant data getting stored
in memory. For instance, if there are 100 students taking C1
course, we don’t need to store its Fee as 1000 for all the 100
records, instead, once we can store it in the second table as
the course fee for C1 is 1000.
Example 2 – Consider following functional dependencies in
relation R (A, B , C, D )
AB -> C [A and B together determine C]
BC -> D [B and C together determine D]
In the above relation, AB is the only candidate key and there is no
partial dependency, i.e., any proper subset of AB doesn’t determine
any non-prime attribute.
X is a super key.
Y is a prime attribute (each element of Y is part of some
candidate key).
Example 1: In relation STUDENT given in Table 4, FD set: {STUD_NO -
> STUD_NAME, STUD_NO -> STUD_STATE, STUD_STATE ->
STUD_COUNTRY, STUD_NO -> STUD_AGE}
Candidate Key: {STUD_NO}
For this relation in table 4, STUD_NO -> STUD_STATE and
STUD_STATE -> STUD_COUNTRY are true.
So STUD_COUNTRY is transitively dependent on STUD_NO. It violates
the third normal form.
To convert it in third normal form, we will decompose the relation
STUDENT (STUD_NO, STUD_NAME, STUD_PHONE, STUD_STATE,
STUD_COUNTRY_STUD_AGE) as: STUDENT (STUD_NO, STUD_NAME,
STUD_PHONE, STUD_STATE, STUD_AGE) STATE_COUNTRY (STATE,
COUNTRY)
Consider relation R(A, B, C, D, E) A -> BC, CD -> E, B -> D, E -> A All
possible candidate keys in above relation are {A, E, CD, BC} All
attributes are on right sides of all functional dependencies are prime.
Example 2: Find the highest normal form of a relation R(A,B,C,D,E)
with FD set as {BC->D, AC->BE, B->E}
Step 1: As we can see, (AC)+ ={A,C,B,E,D} but none of its subset can
determine all attribute of relation, So AC will be candidate key. A or C
can’t be derived from any other attribute of the relation, so there will
be only 1 candidate key {AC}.
Step 2: Prime attributes are those attributes that are part of
candidate key {A, C} in this example and others will be non-prime {B,
D, E} in this example.
Step 3: The relation R is in 1st normal form as a relational DBMS does
not allow multi-valued or composite attribute. The relation is in 2nd
normal form because BC->D is in 2nd normal form (BC is not a proper
subset of candidate key AC) and AC->BE is in 2nd normal form (AC is
candidate key) and B->E is in 2nd normal form (B is not a proper
subset of candidate key AC).
The relation is not in 3rd normal form because in BC->D (neither BC is
a super key nor D is a prime attribute) and in B->E (neither B is a
super key nor E is a prime attribute) but to satisfy 3rd normal for,
either LHS of an FD should be super key or RHS should be prime
attribute. So the highest normal form of relation will be 2nd Normal
form.
For example consider relation R(A, B, C) A -> BC, B -> A and B both
are super keys so above relation is in BCNF.
Third Normal Form
A relation is said to be in third normal form, if we did not have any
transitive dependency for non-prime attributes. The basic condition
with the Third Normal Form is that, the relation must be in Second
Normal Form.
Below mentioned is the basic condition that must be hold in the non-
trivial functional dependency X -> Y:
X is a Super Key.
Y is a Prime Attribute ( this means that element of Y is some
part of Candidate Key).
Unit - 3
Transaction
o The transaction is a set of logically related operation. It contains a group of
tasks.
o A transaction is an action or series of actions. It is performed by a single user
to perform operations for accessing the contents of the database.
X's Account
1. Open_Account(X)
2. Old_Balance = X.balance
3. New_Balance = Old_Balance - 800
4. X.balance = New_Balance
5. Close_Account(X)
Y's Account
1. Open_Account(Y)
2. Old_Balance = Y.balance
3. New_Balance = Old_Balance + 800
4. Y.balance = New_Balance
5. Close_Account(Y)
States of Transaction
In a database, the transaction can be in one of the following states -
Active state
o The active state is the first state of every transaction. In this state, the
transaction is being executed.
o For example: Insertion or deletion or updating a record is done here. But all
the records are still not saved to the database.
Partially committed
o In the partially committed state, a transaction executes its final operation,
but the data is still not saved to the database.
o In the total mark calculation example, a final display of the total marks step is
executed in this state.
Committed
A transaction is said to be in a committed state if it executes all its
operations successfully. In this state, all the effects are now permanently
saved on the database system.
Failed state
o If any of the checks made by the database recovery system fails, then the
transaction is said to be in the failed state.
o In the example of total mark calculation, if the database is not able to fire a
query to fetch the marks, then the transaction will fail to execute.
Aborted
o If any of the checks fail and the transaction has reached a failed state then
the database recovery system will make sure that the database is in its
previous consistent state. If not then it will abort or roll back the transaction
to bring the database into a consistent state.
o If the transaction fails in the middle of the transaction then before executing
the transaction, all the executed transactions are rolled back to its consistent
state.
o After aborting the transaction, the database recovery module will select one
of the two operations:
1. Re-start the transaction
2. Kill the transaction
In this section, we will learn and understand about the ACID properties. We
will learn what these properties stand for and what does each property is
used for. We will also understand the ACID properties with the help of some
examples.
ACID Properties
The expansion of the term ACID defines for:
1) Atomicity
The term atomicity defines that the data remains atomic. It means if any
operation is performed on the data, either it should be performed or
executed completely or should not be executed at all. It further means that
the operation should not break in between or execute partially. In the case of
executing operations on the transaction, the operation should be completely
executed and not partially.
Example: If Remo has account A having $30 in his account from which he
wishes to send $10 to Sheero's account, which is B. In account B, a sum of $
100 is already present. When $10 will be transferred to account B, the sum
will become $110. Now, there will be two operations that will take place. One
is the amount of $10 that Remo wants to transfer will be debited from his
account A, and the same amount will get credited to account B, i.e., into
Sheero's account. Now, what happens - the first operation of debit executes
successfully, but the credit operation, however, fails. Thus, in Remo's
account A, the value becomes $20, and to that of Sheero's account, it
remains $100 as it was previously present.
In the above diagram, it can be seen that after crediting $10, the amount is
still $100 in account B. So, it is not an atomic transaction.
The below image shows that both debit and credit operations are done
successfully. Thus the transaction is atomic.
Thus, when the amount loses atomicity, then in the bank systems, this
becomes a huge issue, and so the atomicity is the main focus in the bank
systems.
2) Consistency
The word consistency means that the value should remain preserved
always. In DBMS, the integrity of the data should be maintained, which
means if a change in the database is made, it should remain preserved
always. In the case of transactions, the integrity of the data is very essential
so that the database remains consistent before and after the transaction.
The data should always be correct.
Example:
In the above figure, there are three accounts, A, B, and C, where A is making
a transaction T one by one to both B & C. There are two operations that take
place, i.e., Debit and Credit. Account A firstly debits $50 to account B, and
the amount in account A is read $300 by B before the transaction. After the
successful transaction T, the available amount in B becomes $150. Now, A
debits $20 to account C, and that time, the value read by C is $250 (that is
correct as a debit of $50 has been successfully done to B). The debit and
credit operation from account A to C has been done successfully. We can see
that the transaction is done successfully, and the value is also read correctly.
Thus, the data is consistent. In case the value read by B and C is $300, which
means that data is inconsistent because when the debit operation executes,
it will not be consistent.
3) Isolation
The term 'isolation' means separation. In DBMS, Isolation is the property of a
database where no data should affect the other one and may occur
concurrently. In short, the operation on one database should begin when the
operation on the first database gets complete. It means if two operations are
being performed on two different databases, they may not affect the value of
one another. In the case of transactions, when two or more transactions
occur simultaneously, the consistency should remain maintained. Any
changes that occur in any particular transaction will not be seen by other
transactions until the change is not committed in the memory.
4) Durability
Durability ensures the permanency of something. In DBMS, the term
durability ensures that the data after the successful execution of the
operation becomes permanent in the database. The durability of the data
should be so perfect that even if the system fails or leads to a crash, the
database still survives. However, if gets lost, it becomes the responsibility of
the recovery manager for ensuring the durability of the database. For
committing the values, the COMMIT command must be used every time we
make changes.
Therefore, the ACID property of DBMS plays a vital role in maintaining the
consistency and availability of data in the database.
Concurrency Control
Concurrency Control is the working concept that is required for controlling
and managing the concurrent execution of database operations and thus
avoiding the inconsistencies in the database. Thus, for maintaining the
concurrency of the database, we have the concurrency control protocols.
For example:
Consider the below diagram where two transactions T X and TY, are
performed on the same account A where the balance of account A is
$300.
o At time t1, transaction TX reads the value of account A, i.e., $300 (only read).
o At time t2, transaction TX deducts $50 from account A that becomes $250
(only deducted and not updated/write).
o Alternately, at time t3, transaction T Y reads the value of account A that will be
$300 only because TX didn't update the value yet.
o At time t4, transaction TY adds $100 to account A that becomes $400 (only
added but not updated/write).
o At time t6, transaction T X writes the value of account A that will be updated
as $250 only, as TY didn't update the value yet.
o Similarly, at time t7, transaction T Y writes the values of account A, so it will
write as done at time t4 that will be $400. It means the value written by T X is
lost, i.e., $250 is lost.
For example:
For example:
o At time t1, transaction TX reads the value from account A, i.e., $300.
o At time t2, transaction TY reads the value from account A, i.e., $300.
o At time t3, transaction TY updates the value of account A by adding $100 to
the available balance, and then it becomes $400.
o At time t4, transaction TY writes the updated value, i.e., $400.
o After that, at time t5, transaction T X reads the available value of account A,
and that will be read as $400.
o It means that within the same transaction T X, it reads two different values of
account A, i.e., $ 300 initially, and after updation made by transaction T Y, it
reads $400. It is an unrepeatable read and is therefore known as the
Unrepeatable read problem.
Types of Serializability
There are two ways to check whether any non-serial schedule is
serializable.
R(a)
R(b)
R(b)
W(b)
W(a)
W(a)
R(a)
W(a)
2. View Serializability
View serializability is a kind of operation in a serializable in which
each transaction should provide some results, and these outcomes
are the output of properly sequentially executing the data item. The
view serializability, in contrast to conflict serialized, is concerned with
avoiding database inconsistency. The view serializability feature of
DBMS enables users to see databases in contradictory ways.View
Serializability refers to the process of determining whether a
schedule’s views are equivalent.
Example
We have a schedule “S” with two concurrently running transactions,
“t1” and “t2.”
Schedule – S:
Transaction-1 Transaction-2
(t1) (t2)
R(a)
W(a)
R(a)
W(a)
R(b)
W(b)
R(b)
W(b)
R(a)
W(a)
R(b)
Transaction-1 Transaction-2
(t1) (t2)
W(b)
R(a)
W(a)
R(b)
W(b)
Unit-4
1. DAC (Discretionary Access Control):
Definition: DAC is a model of access control where the owner of
an object (e.g., a file or a database table) has discretion over
who can access and manipulate that object. In other words, the
owner of the resource can grant or revoke permissions to other
users or entities.
Key Features:
Users have the discretion to control access to their own
resources.
Typically, permissions are associated with individual users
or groups, and the owner decides who gets what level of
access.
Common implementations include file-level permissions on
operating systems and some database systems that allow
users to grant privileges to others.
User A, who created the folder, can decide to grant read and write
access to User B and read-only access to User C.
User B, with the granted permissions, can further decide to allow or
deny access to User D for specific files within the folder.
User C may decide to restrict access to a subfolder for User A.
In this example, access decisions are not at the discretion of individual users
but are determined by the security labels and the security policy, making it a
MAC system.
It's important to note that these access control models can sometimes be
used in combination within a DBMS, depending on the security requirements
of the organization and the sensitivity of the data being managed. For
example, an organization might use MAC for highly classified data, DAC for
less sensitive data, and RBAC for managing access to various applications
and systems within the organization.
. Intrusion Detection:
Steps:
SQL Injection:
SQL injection is a specific type of cyberattack that targets vulnerabilities in a DBMS by injecting
malicious SQL code into user inputs. This code can exploit vulnerabilities to gain unauthorized
access to the database or manipulate its contents. SQL injection attacks often occur when user
inputs are not properly validated or sanitized before being used in SQL queries.
Here's a simplified example of an SQL injection attack:
Suppose a website has a search box that allows users to search for products by name. The
website's code might construct an SQL query like this:
In this case, the attacker has injected SQL code that always evaluates to true (1=1), effectively
bypassing any authentication and potentially gaining unauthorized access to all product records.
To prevent SQL injection, developers should use parameterized queries or prepared statements,
which separate user input from the SQL query and automatically handle input sanitization.
Intrusion detection systems can help detect SQL injection attempts by monitoring database
activity for unusual SQL queries, unexpected patterns, or signs of unauthorized access. When
suspicious activity is detected, the IDS can trigger alerts or take action to mitigate the threat.
In summary, intrusion detection systems are crucial for identifying and responding to security
threats in a DBMS, including SQL injection attacks, which are a common and potentially
damaging form of attack that targets vulnerabilities in database queries.
Data Warehousing:
Imagine you have a big store, and you want to keep track of all the items
you sell and how much money you make. You collect this information every
day and store it in a special place called a "warehouse" just for this data.
Data Warehouse: It's like a giant storage room for all your business
data, where you organize and keep records of everything that happens
in your store. It's designed to make it easy to find and use this
information whenever you need it.
Data Mining:
Now that you have this treasure trove of data in your warehouse, you want
to do something useful with it. Data mining is like having a team of
detectives go through all the information to find hidden patterns, valuable
insights, and answers to important questions.
Data Mining: It's the process of digging through your stored data to
discover things you might have missed. It helps you find trends, make
predictions, and uncover valuable information, kind of like solving
mysteries hidden in your data.
Main Function Data storage and organization. Data analysis and pattern discovery.
Example Use Storing sales data from multiple Discovering which products are often
Case stores in one place. bought together.