2. A person, place, event or item is called an entity
The facts describing an entity are known as data
Each entity can be described by its characteristics
known as attributes
All the related entities are collected together to
form an entity set
A database is a collection of entity sets
The interaction between the entity sets are called
relationships.
2
3. A data base is an electronic store of data.
It stores information about different “things”& also
contains relationships.
The collection of data may be organized in the
form of files or tables.
Examples:-
1. Oracle 9i, 10G, 10Gi, 11G, 11Gi
2. SQL-server-2005, 2010
3. DB2,Sybase,foxpro, Ms-access2003,2007, 2010,
3
4. A DBMS is a software package designed to define,
manipulate, retrieve and manage data in a database.
It also defines rules to validate and manipulate the
data.
It relieves users of framing programs for data
maintenance.
Fourth-generation query languages, such as SQL, are
used along with the DBMS package to interact with a
database.
4
6. 1. One-to-one (1:1) :
Each entity has only one matching entity in another
entity set
Eg: Student (1) – RollNo. (1)
2. One-to-many (1:M):
Each entity of X has many matching entities in
another entity set Y.
Eg: Department (1) – Employees (M)
3. Many-to-many (M:M):
Each entity of X has many matching entities in
another entity set Y and vice versa.
Eg: Students (M) – Courses (M)
6
7. DBMS S/W Packages – MS Access, Oracle
User developed & implemented DB
Custom Applications such as forms,Reports,query
blocks
Computer hardware – PCs, minicomputers
Software – OS and Network OS
Personnel- DB administrator, designer
7
9. RDBMS is a DBMS i.e. based on Relational model as
introduce by Dr. E.F. Codd…..
Codd’s rule for RDBMS:-
Dr. Codd is an IBM researcher who developed
relational data base in 1970…..
In 1905 Codd published 12 rules……
1)The Information rule.
2)Granted access rule.
3)Systemic treatment of NULL values.
4)Dynamic online Catalog based on relational model.
9
10. 5)Comprehensive data sub-language rule.
6)View updating rule.
7)High level Insert , Update, Delete rule.
8)Physical data Independence.
9)Logical data Independence.
10)Integrity data Independence.
11)Distribution data Independence.
12)Non-subversions rule.
10
11. 1. It manages the data and relationships stored
in the database.
2. It creates a Data Dictionary (DD) as a user
creates a DB. DD stores Metadata (data
about data)
3. Manages all day-to-day transactions
4. Data search can be done through DD
5. User can validate data
11
12. 6. Secures access through passwords, encryption
etc..
7. Backup & Recovery procedures
8. Data Sharing with data-locking capabilities
9. Import and Export Utilities from other databases
10. Users can view information stored in different
tables within the database.
12
14. E.F.Codd developed the relational model in 1970.
The relation is represented by a table structure
Each row represents an entity
Each column represents an attribute
DATA STRUCTURES - domain, attribute, relation,
tuple, primary key, degree, cardinality.
INTEGRITY CONSTRAINTS - entity integrity and
referential integrity.
DATA MANIPULATION OPERATIONS - defined
through relational algebra and equivalent relational
calculus.
14
15. A database consists of one or more relations.
A relation is described by a name, names for one
or more attributes and consists of zero or more
tuples.
A tuple consists of values for each attribute of the
relation.
An attribute takes values from a domain and
there exists one value for each attribute in a tuple.
A domain consists of all allowed atomic values for
one or more attributes.
Degree of a relation is the number of attributes of
the relation.
Cardinality of a relation is the number of tuples of
the relation.
15
19. Keys are very important part of Relational
database.
They are used to establish and identify relation
between tables.
They also ensure that each record within a table
can be uniquely identified by combination of one
or more fields within a table.
19
20. Super Key:
Super Key is defined as a set of attributes within
a table that uniquely identifies each record within a
table.
Super Key is a superset of Candidate key.
Candidate Key:
Candidate keys are defined as the set of fields
from which primary key can be selected.
It is an attribute or set of attributes that can act as
a primary key for a table to uniquely identify each
record in that table.
20
22. The minimal set of attribute which can uniquely identify a tuple is
known as candidate key.
For Example, STUD_NO in STUDENT relation.
The value of Candidate Key is unique and non-null for every tuple.
There can be more than one candidate key in a relation.
For Example, STUD_NO as well as STUD_PHONE both are
candidate keys for relation STUDENT.
The candidate key can be simple (having only one attribute) or
composite as well.
For Example, {STUD_NO, COURSE_NO} is a composite candidate
key for relation STUDENT_COURSE.
22
23. The set of attributes which can uniquely identify a
tuple is known as Super Key.
For Example, STUD_NO, (STUD_NO,
STUD_NAME) etc.
Adding zero or more attributes to candidate key
generates super key.
A candidate key is a super key but vice versa is
not true
23
24. There can be more than one candidate key in a
relation out of which one can be chosen as
primary key( that is most appropriate to become
main key of the table)
For Example, STUD_NO as well as
STUD_PHONE both are candidate keys for
relation STUDENT but STUD_NO can be chosen
as primary key (only one out of many candidate
keys).
24
25. The candidate key other than primary key is called
as alternate key.
For Example, STUD_NO as well as
STUD_PHONE both are candidate keys for
relation STUDENT but STUD_PHONE will be
alternate key (only one out of many candidate
keys).
25
26. If we use multiple attributes to create a Primary
Key then that Primary Key is called Composite
Key (also called a Compound Key or
Concatenated Key).
26
27. A foreign key is an attribute or combination of attributes
in one base table that points to the candidate key
(generally it is the primary key) of another table.
The purpose of the foreign key is to ensure referential
integrity of the data
For Example, STUD_NO in STUDENT_COURSE is a
foreign key to STUD_NO in STUDENT relation.
27
28. It is very important that data in the underlying tables be
consistent
Two integrity rules:
1. Entity Integrity (feature of primary key)
◦ No column in primary key may be null
◦ Primary key provides the means of uniquely identifying a row or
an entity.
◦ A null value means a value that is not known, not entered, not
defined or not applicable.
28
29. ◦ A zero or space is not considered to be a null
value
◦ RDBMS does not allow users to enter a row
without a unique value in the primary key column
2. Referential Integrity(feature of foreign key)
◦ Foreign key value may be null or it must exist as a value
of a primary key in the referenced table.
◦ Oracle does not allow to declare a foreign key if it does
not exist as a primary key in another table
29
30. Relational algebra , a procedural language
Relational calculus, a non-procedural language
30
31. 31
Relational algebra is a collection of operations to
manipulate or access tables
It is a procedural language with operations
performed on one or more existing relations to
derive resulting operations without changing the
original relations.
The operations can be divided into two groups
SET-ORIENTED OPERATIONS
NATIVE(SPECIAL)RELATIONAL
OPERATIONS.
Basics of Relational
Algebra
32. 32
BASIC SET ORIENTED OPERATIONS
NAME SYMBOL
UNION U
INTERSECTION ∩
DIFFERENCE -
PRODUCT ×
NATIVE RELATIONAL OPERATIONS
NAME SYMBOL
SELECTION σ
PROJECTION Π
JOIN
DIVISION ÷
ASSIGNMENT
33. 33
UNION
ROLL.NO NAME
12505 SHARAN
12506 SANGEETA
12507 SHYNA
A
B
ROLL.NO NAME
12502 PRABJOT
125O7 SHYNA
12520 POOJA
12521 RINKI
ROLL.NO NAME
12502 PRABJOT
12505 SHARAN
12506 SANGEETA
12507 SHYNA
12520 POOJA
12521 RINKI
R=AUB
35. 35
DIFFERENCE
B
A
ROLL.NO NAME
12502 PRABJOT
12505 SHARAN
12507 SHYNA
12521 RINKI
ROLL.NO NAME
12507 SHYNA
12519 POOJA
12514 NEETU
12521 RINKI
R=A-B
ROLL.NO NAME
12502 PRABJOT
12505 SHARAN
R=B-A
ROLL.NO NAME
12519 POOJA
12514 NEETU
36. 36
CARTESIAN PRODUCT
ROLL.NO NAME
12502 PRABJOT
12505 SHARAN
12507 SHYNA
12521 RINKI
A
ROLL.NO NAME
12507 SHYNA
12519 POOJA
B
R=A×B
ROLL.NO NAME ROLL.NO NAME
12502 PRABJOT 12507 SHYNA
12502 PRABJOT 12519 POOJA
12505 SHARAN 12507 SHYNA
12505 SHARAN 12519 POOJA
12507 SHYNA 12507 SHYNA
12507 SHYNA 12519 POOJA
12521 RINKI 12507 SHYNA
12521 RINKI 12521 POOJA
37. 37
ID NAME SALARY AGE
101 AMIT 4500 30
102 AJAY 5000 35
105 JOHN 5000 36
106 ABHI 4000 28
107 ALI 4800 31
108 SUNIL 3500 33
EMPLOYEE
SELECTION
RESULTING TABLE
σAGE >32 (EMPLOYEE)
ID NAME SALARY AGE
102 AJAY 5000 35
105 JOHN 5000 36
108 SUNIL 3500 33
38. 38
PROJECTION
EMPLOYEE
ID NAME SALARY AGE
101 AMIT 4500 30
102 AJAY 5000 35
105 JOHN 5000 36
106 ABHI 4000 28
107 ALI 4800 31
108 SUNIL 3500 33
109 JOHN 4600 29
RESULTING TABLES
A. π ID (EMPLOYEE)
B. π NAME,AGE (EMPLOYEE)
NAME AGE
AMIT 30
AJAY 35
JOHN 36
ABHI 28
ALI 31
SUNIL 33
JOHN 29
ID
101
102
105
106
107
108
109
B
A
41. 41
DIVISION
NAME COUR
SE
A1 B1
A3 B2
A2 B3
A2 B1
A1 B3
A3 B3
A3 B1
COURSE
B1
B3
COURS
E
B2
COURSE
B2
B3
MAIN
R1
SUB2 SUB3
RESULTING TABLES
R3
R3MAIN÷SUB3
R2
NAME
A1
A2
A3
NAME
A3
NAME
A3
R1MAIN ÷ SUB1
R2MAIN÷SUB2
SUB1
ASSIGNMENT
Eg: Student enrolled in
ALL the courses
42. Non Procedural
Programmer specifies data requirement
General Syntax:
result=(column list):expression
Example:
r.Name:r in Employee and r.age<30
Result:
42
Name
ABHI
JOHN