Copy of DBMS Unit 2
Copy of DBMS Unit 2
MODEL
Relational Model
Basic structure of relational databases
Database schema,
Relational algebra-Fundamental,
Operations
RELATIONAL MODEL
Relation Schema
Relation Instance
Domain
Degree
Cardinality
NULL Values
Structure of Relational
Databases(cont….)
Attribute (column Headers):
Relational Schema.
RELATION INSTANCE:
The set of tuples of a relation at a particular instance of
time is called as relation instance.
Table shows the relation instance of STUDENT at a
particular time.
It can change whenever there is insertion, deletion or
updation in the database.
Ex. t1 Relation instance. And After deletion t2 relation
instance
DOMAIN:
For each attribute of a relation, there is a set of
permitted values, called the domain of that
attribute.
It contains a set of atomic(indivisible) values
be in between 20-50.
Degree: The number of attributes in the relation is known
as degree of the relation. The STUDENT relation defined
above has degree 5.
Cardinality: The number of tuples in a relation is known as
cardinality. The STUDENT relation defined above has
cardinality 4.
NULL Values: The value which is not known or unavailable
is called NULL value. It is represented by blank space. e.g.;
PHONE of STUDENT having ROLL_NO 4 is NULL.
DATABASE SCHEMA
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
tables.
Keys help you uniquely identify a row in a table
PERSON table.
The key which is most suitable from those lists
key.
For example: In the EMPLOYEE table, id is best
procedural or non-procedural.
PROCEDURAL QUERY LANGUAGE
language.
NON-PROCEDURAL QUERY LANGUAGE
Non-procedural queries will have single query on
one or more tables to get result from the
database.
For example, get the name and address of the
Notation: σ p(r)
Where:
σ is used for selection prediction
predicate.
Notation − ∏
A1, A2, An (r)
Notation: R - S
in s.
Example:
∏
author (Books) − ∏ author (Articles)
defined as −
σauthor = ‘ADAM'(Books Χ Articles)
Output −
Yields a relation, which shows all the books and
Query: R X S
RENAME OPERATION:
The results of relational algebra are also relations
but without any name.
The rename operation allows us to rename the
Example:
ρ(STUDENT1, STUDENT)
P = R ⋈ S
Where,
tuples in R.
It is denoted by ⟖.
Input =A ⟖ B
FULL (OUTER) JOIN:
Returns all records when there is a match in either
left or right table.
Full outer join is like a left or right join except that it
Generalized Projection
Aggregate Functions
GENERALIZED PROJECTION
The generalized-projection operation extends the projection
operation by allowing arithmetic functions to be used in the
projection list.
The generalized projection operation has the form
∏ F1,F2,...,Fn (E)
where
E is any relational-algebra expression, and
each of F1, F2, . . . , Fn is an arithmetic expression involving
constants and attributes in the schema of E an expression can
use arithmetic operations such as +,−, ∗, and ÷ on numeric
valued attributes, numeric constants, and on expressions that
generate a numeric result.
Generalized projection also permits operations on other data
types, such as concatenation of strings.
Ex. Given relation instructor(ID, name, dept_name, salary)
where salary is annual salary, get the same information but
with monthly salary
∏ID, name, dept_name, salary/12 (instructor)
AGGREGATE FUNCTIONS
Aggregation function takes a collection of values and
returns a single value as a result.
avg: average value