RS3862 - Grade - 10 Database Management System
RS3862 - Grade - 10 Database Management System
RS3862 - Grade - 10 Database Management System
10
Government of Nepal
Ministry of Education, Science and Technology
Curriculum Development Centre
Sanothimi, Bhaktapur
Phone : 5639122/6634373/6635046/6630088
Website : www.moecdc.gov.np
Feedback Copy
Secondary Level
Computer Engineering
Government of Nepal
Ministry of Education, Science and Technology
Curriculum Development Centre
Sanothimi, Bhaktapur
Publisher : Government of Nepal
Ministry of Education, Science and Technology
Curriculum Development Centre
Sanothimi, Bhaktapur
© Publisher
The curriculum and curricular materials have been developed and revised on a regular
basis with the aim of making education objective-oriented, practical, relevant and job
oriented. It is necessary to instill the feelings of nationalism, national integrity and
democratic spirit in students and equip them with morality, discipline and self-
reliance, creativity and thoughtfulness. It is essential to develop in them the linguistic
and mathematical skills, knowledge of science, information and communication
technology, environment, health and population and life skills. it is also necessary to
bring in them the feeling of preserving and promoting arts and aesthetics, humanistic
norms, values and ideals. It has become the need of the present time to make them
aware of respect for ethnicity, gender, disabilities, languages, religions, cultures,
regional diversity, human rights and social values so as to make them capable of
playing the role of responsible citizens with applied technical and vocational
knowledge and skills. This Learning Resource Material for Computer Engineering has
been developed in line with the Secondary Level Computer Engineering Curriculum
with an aim to facilitate the students in their study and learning on the subject by
incorporating the recommendations and feedback obtained from various schools,
workshops and seminars, interaction programs attended by teachers, students and
parents.
In bringing out the learning resource material in this form, the contribution of the
Director General of CDC Dr. Lekhnath Poudel, Pro, Dr. Subarna Shakya, Bibha
Sthapit, Anil Barma, Yogesh Parajuli, Nabinkrishna Maskey, Rajendra Rokaya, Lina
Maharjan, Bimal Thapa, Shankar Yadav is highly acknowledged. The book is written
by Satyaram Suwal and the subject matter of the book was edited by Badrinath
Timalsina and Khilanath Dhamala. CDC extends sincere thanks to all those who have
contributed in developing this book in this form.
This book is a supplimentary learning resource material for students and teachrs. In
addition they have to make use of other relevnt materials to ensure all the learning
outcomes set in the curriculum. The teachers, students and all other stakeholders are
expected to make constructive comments and suggestions to make it a more useful
learning resource material.
Objectives
After completion of this unit students will be able
To explain the concept of Database System concept
to state Database Manager and users
to discuss the needs of organization of database
to apply the knowledge of Client-Server Architecture
It is clear from the above file systems, that there is some common data of the student
which has to be mentioned in each application, like Roll number, Name, Class, Phone
No~ Address etc. This will cause the problem of redundancy which results in
wastage of storage space and difficult to maintain, but in case of centralized database,
It is clear in the above database that Rollno, Name, Class, Father_Name, Address,
Phone_No, Date of_birth which are stored repeatedly in file system in each
application, need not be stored repeatedly in case of database, because every other
application can access this information by joining of relations on the basis of
common column i.e. Rollno. Suppose any user of Library system need the Name,
Address of any particular student and by joining of Library and General Office
relations on the basis of column Rollno he/she can easily retrieve this information.
Thus, we can say that centralized system of DBMS reduces the redundancy of data
to great extent but cannot eliminate the redundancy because RollNo is still repeated
in all the relations.
2. Integrity can be enforced: Integrity of data means that data in database is always
accurate, such that incorrect information cannot be stored in database. In order to
maintain the integrity of data, some integrity constraints are enforced on the
database. A DBMS should provide capabilities for defining and enforcing the
constraints.
For Example: Let us consider the case of college database and suppose that college
having only BTech, MTech, MSc, BCA, BBA and BCOM classes. But if a user
enters the class MCA, then this incorrect information must not be stored in database
and must be prompted that this is an invalid data entry. In order to enforce this, the
integrity constraint must be applied to the class attribute of the student entity. But, in
Database Architecture
Centralized database
Earlier architectures used mainframe computers to provide the main processing for
all system functions, including user application programs and user interface
programs, as well as all the DBMS functionality. The reason was that most users
accessed such systems via computer terminals that did not have processing power
and only provided display capabilities. Therefore, all processing was
performed remotely on the computer system, and only display information and
controls were sent from the computer to the display terminals, which were connected
to the central computer via various types of communications networks.
Two-tier Client / Server architecture is used for User Interface program and
Application Programs that runs on client side. An interface called ODBC (Open
Database Connectivity) provides an API that allow client side program to call the
dbms. Most DBMS vendors provide ODBC drivers. A client program may connect
to several DBMS's. In this architecture some variation of client is also possible for
example in some DBMS's more functionality is transferred to the client including
data dictionary, optimization etc. Such clients are called Data server.
Objective:
After completion of this unit students will be able
To distinguish between entity and attributes
To identify entity set and keys
To practice the knowledge of mapping Cardinalities
Content’s Elaboration:
Entity Relationship Model
Entity–relationship modeling was developed for database design by Peter Chen and
published in a 1976 paper. However, variants of the idea existed previously. Some
ER models show super and subtype entities connected by generalization-
specialization relationships, and an ER model can be used also in the specification
of domain-specific ontologies.
An ER model is typically implemented as a database. In a simple relational database
implementation, each row of a table represents one instance of an entity type, and
each field in a table represents an attribute type. In a relational database a relationship
between entities is implemented by storing the primary key of one entity as a pointer
or "foreign key" in the table of another entity
Entity Relationship Diagram
An entity-relationship (ER) diagram is a graphical representation of entities (which
will become your tables) and their relationships to each other.
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 −
Entity
An entity in an ER Model is a real-world entity having properties called attributes.
Every attribute is defined by its set of values called domain. For example, in a
school database, a student is considered as an entity. Student has various attributes
like name, age, class, etc.
Entity Set:
An Entity is an object of Entity Type and set of all entities is called as entity set. e.g;
E1 is an entity having Entity Type Student and set of all students is called Entity Set.
In ER diagram, Entity Type is represented as:
Attribute:
An attribute defines the information about the
entity that needs to be stored. An attribute
describes the facts, details or characteristics of
an entity. If the entity is employee, attributes
could include: name, employee ID, health plan
enrollment and work location.
Types of Attributes
Attributes can be classified as having many
parts to them or just a single unbreakable
attribute.
The above example describes that one student can enroll only for one course and a
course will also have only one Student. This is not what you will usually see in
relationship.
One to Many: It reflects business rule that one entity is associated with many
number of same entity. The example for this relation might sound a little weird, but
this means that one student can enroll to many courses, but one course will have one
Student.
The above diagram describes that one student can enroll for only one course.
Many to One: It reflects business rule that many entities can be associated with just
one entity. For example, Student enrolls for only one Course but a Course can have
many Students.
The above diagram describe many students can enroll in one course.
Many to Many:
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.
The above diagram represents that many students can enroll for more than one
courses.
E-R Diagram
ER-Diagram is a visual representation of data that describes how data is related to
each other.
Objectives:
After completion of this unit students will be able
To memorize Relational Database Model
To tell Structure Query Language.
Content’s Elaboration:
Entity-Relationship model
An entity-relationship model (ERM) is a theoretical and conceptual way of showing
data relationships in software development. ERM is a database modeling technique
that generates an abstract diagram or visual representation of a system’s data that can
be helpful in designing a relational database. These diagrams are known as entity-
relationship diagrams, ER diagrams or ERDs. Entity-relationship patterns were first
proposed by Peter Pin-Shan Chen of the Massachusetts Institute of Technology
(MIT) in 1976.
The building blocks of an ERD are entities, relationships and attributes. Entities have
entity types, which are known as instances of the corresponding entities. Each entity
type can exist independently of another; for example, the entity "vehicle" can have
the entity types "car" and "bus." Relationship is the property that links the entity
types together. For example, the entity type husband is related to the entity type wife
by a relationship known as "is-married-to." Attributes are properties that belong to
the entity types as well as to the relationships. There are a number of ER
diagramming tools available on the market. The most common ones are MySQL
Workbench and OpenModelSphere.
1 Ram 34 13000
2 Pema 28 15000
3 John 20 18000
4 Yadav 42 19020
Record
A single entry in a table is called a Record or Row. A Record in a table represents
set of related data. For example, the above Employee table has 4 records. Following
is an example of single record.
RAM 34 13000
Name
Adam
Alex
Stuart
Ross
Above diagram describe the relationship between table in relational database model.
Constraints in Relational Model
While designing Relational Model, we define some conditions which must hold for
data present in database are called Constraints. These constraints are checked before
performing any operation (insertion, deletion and updation) in database. If there is a
violation in any of constrains, operation will fail.
Domain Constraints: These are attribute level constraints. An attribute can only
take values which lie inside the domain range. e.g.,; If a constrains AGE>0 is applied
on STUDENT relation, inserting negative value of AGE will result in failure.
4 SURESH DELHI 18 IT
BRANCH
BRANCH_CODE BRANCH_NAME
CS COMPUTER SCIENCE
IT INFORMATION TECHNOLOGY
CV CIVIL ENGINEERING
BRANCH_CODE of STUDENT can only take the values which are present in
BRANCH_CODE of BRANCH which is called referential integrity constraint. The
Outer JOIN
Outer Join is based on both matched and unmatched data. Outer Joins subdivide
further into,
Left Outer Join
Right Outer Join
Full Outer Join
ID NAME
1 abhi
2 adam
3 alex
4 anu
5 ashish
1 KATHAMANDU
2 BHAKTAPUR
3 POKHARA
7 CHITWAN
8 PATAN
ID NAME ID Address
1 abhi 1 KATHAMANDU
2 adam 2 BHAKTAPUR
3 alex 3 POKHARA
ID NAME
1 abhi
2 adam
3 alex
4 anu
5 ashish
ID Address
1 KATHAMANDU
2 BHAKTAPUR
3 POKHARA
7 CHITWAN
8 PATAN
ID NAME ID Address
1 abhi 1 KATHAMANDU
2 adam 2 BHAKTAPUR
3 alex 3 POKHARA
1 abhi
2 adam
3 alex
ID Address
1 KATHAMANDU
2 BHAKTAPUR
3 POKHARA
ID NAME ID Address
1 abhi 1 KATHAMANDU
2 adam 2 BHAKTAPUR
3 alex 3 POKHARA
Command Description
Command Description
Command Description
Command Description
Objective
After completion of this unit students will be able
To distinguish between Trivial and Non-trivial
To demonstrate closure of a set of Attributes
To practice the knowledge of Normalization
Content’s Elaboration:
Introduction: while designing a database out of an entity-relationship mode, the
main problem existing in that raw database is redundancy. redundancy is storing the
same data item in more one place. A redundancy creates several problems like the
following:
Extra storage space: strong the same data in many places takes large amount of
disk pace.
Entering same data more than once during data insertion.
Deleting data from more than one place during deletion.
Modifying data in more than one place.
Anomalies may occur in the database if insertion, deletion, modification etc. are
no done properly.
It creates inconsistency and unreliability in the database.
if result
then result := result ;
end
Each attribute must contain only a single value from its pre-defined domain.
Second Normal Form
Before we learn about the second normal form, we need to understand the following−
Prime attribute − An attribute, which is a part of the candidate-key, is known
as a prime attribute.
Non-prime attribute − An attribute, which is not a part of the prime-key, is said
to be a non-prime attribute.
If we follow second normal form, then every non-prime attribute should be fully
functionally dependent on prime key attribute. That is, if X → A holds, then there
should not be any proper subset Y of X, for which Y → A also holds true.
We broke the relation in two as depicted in the above picture. So there exists no
partial dependency.
Third Normal Form
For a relation to be in Third Normal Form, it must be in Second Normal form and
the following must satisfy −
No non-prime attribute is transitively dependent on prime key attribute.
For any non-trivial functional dependency, X → A, then either −
X is a superkey or,
A is prime attribute.
Key points:
Normalization is a step by step process of removing different kinds of
redundancy and normally at each step.
Functional Dependencies: The attributes of a table is said to be dependent on
each other when an attribute of a table uniquely identifies another attribute of
the same table.
Trivial functional dependency: The dependency of an attribute on a set of
attributes is known as trivial functional dependency if the set of attributes
includes that attribute.
Non trivial functional dependency: If a functional dependency X->Y holds true
where Y is not a subset of X then this dependency is called non trivial Functional
dependency.
UNIT 5
Concurrency Control and recovery
Objectives
After completion of this unit students will be able
To identify the transaction
To describe the properties of transaction
To illustrate the knowledge of state of transaction
To memorize the requirements for recovery
Content’s Elaboration:
Introduction Of transaction
A transaction can be defined as a group of tasks. A single task is the minimum
processing unit which cannot be divided further.
Let’s take an example of a simple transaction. Suppose a bank employee transfers
Rs 500 from A's account to B's account. This very simple and small transaction
involves several low-level tasks.
A’s Account
Open_Account(A)
Old_Balance = A.balance
New_Balance = Old_Balance - 500
A.balance = New_Balance
Close_Account(A)
B’s Account
Open_Account(B)
States of Transactions
A transaction in a database can be in one of the following states −
Active − In this state, the transaction is being executed. This is the initial state
of every transaction.
Partially Committed − When a transaction executes its final operation, it is said
to be in a partially committed state.
Failed − A transaction is said to be in a failed state if any of the checks made by
the database recovery system fails. A failed transaction can no longer proceed
further.
Aborted − If any of the checks fails and the transaction has reached a failed
state, then the recovery manager rolls back all its write operations on the
database to bring the database back to its original state where it was prior to the
execution of the transaction. Transactions in this state are called aborted. The
The recovery system reads the logs backwards from the end to the last
checkpoint.
It maintains two lists, an undo-list and a redo-list.
If the recovery system sees a log with <Tn, Start> and <Tn, Commit> or just <Tn,
Commit>, it puts the transaction in the redo-list.
If the recovery system sees a log with <Tn, Start> but no commit or abort log
found, it puts the transaction in undo-list.
All the transactions in the undo-list are then undone and their logs are removed. All
the transactions in the redo-list and their previous logs are removed and then redone
before saving their logs.
Objectives
After completion of this unit students will be able
To state the security of DBMS
To recognize Access Control
To tell statistical Database
To discuss with data encryption technique.
Content’s Elaboration:
Database Security and Threats
Data security is an imperative aspect of any database system. It is of particular
importance in distributed systems because of large number of users, fragmented and
replicated data, multiple sites and distributed control.
Threats in a Database
Availability loss − Availability loss refers to non-availability of database
objects by legitimate users.
Integrity loss − Integrity loss occurs when unacceptable operations are
performed upon the database either accidentally or maliciously. This may
happen while creating, inserting, updating or deleting data. It results in corrupted
data leading to incorrect decisions.
Confidentiality loss − Confidentiality loss occurs due to unauthorized or
unintentional disclosure of confidential information. It may result in illegal
actions, security threats and loss in public confidence.
Here we will discuss a sample hashing algorithm in which we will multiply the
number of a’s, e’s and h’s in the message and will then add the number of o’s to this
value.
For example, the message is “ the combination to the safe is two, seven, thirty-five”.
The hash of this message, using our simple hashing algorithm is as follows:
2 x 6 x 3 ) + 4 = 40
The hash of this message is sent to John with cipher text. After he decrypts the
message, he computes its hash value using the agreed upon hashing algorithm. If the
hash value sent by Bob doesn’t match the hash value of decrypted message, John
will know that the message has been altered.
For example, John received a hash value of 17 and decrypted a message Bob has sent
as “You are being followed, use backroads, hurry”
He could conclude the message had been altered, this is because the hash value of
the message he received is:
(3x4x1)+4 = 16
This is different from then value 17 that Bob sent.
Exercises:
Very Short Question Answer
a. Define Database security.
b. What is thereat ?
c. What is encryption mean in database security ?
d. Define cipher text.
e. Who is responsible for overall security of the database system.
Short Question Answer
a. List out the different threats in Database System.
b. What are the measures of control use in Database System?
c. List out the role of DBA in Database Security.
d. Write the threats found in Database.
e. Classify the Database Security.
Long Question Answer
a) Explain the role of DBA in Database Security in detail.
b) Describe the method of Database Security Essentials.
c) What is Discretionary Access Control? Write its attributes.
d) Differentiate between Private Key cryptography and Public Key
cryptography.
e) What is digital signature? whey it is important ?
References:
https://www.tutorialspoint.com/distributed_dbms/distributed_dbms_database_secur
ity_cryptography.htm
http://www.dbta.com/Editorial/Think-About-It/5-Key-Steps-to-Ensuring-Database-
Security-95307.aspx