0% found this document useful (0 votes)
60 views4 pages

Relational Algebra

The document discusses various relational algebra operations including select, project, union, set difference, cartesian product, and rename. It defines each operation and provides examples of how they are used and expressed in relational algebra notation. Additional extended operators like DNF, ALL, SOME and EXISTS are also mentioned along with their purpose.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views4 pages

Relational Algebra

The document discusses various relational algebra operations including select, project, union, set difference, cartesian product, and rename. It defines each operation and provides examples of how they are used and expressed in relational algebra notation. Additional extended operators like DNF, ALL, SOME and EXISTS are also mentioned along with their purpose.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

3.

12 Relational Model

3.3.2.4 Key constraints


Keys arc the entity set that is used to identify an entity within
its entity set
There must be at least one minimal subset
atuple uniqucly. This minimal subset of
ofattributes in the relation,
attributes is called key for which
ucannriqueidlyen.
is more than one such minimal
subset, these are called candidate keys.
that relation.
Key constraints force that -
in a relation with a key
attributes.
attribute, no two tuples can have
identical values for L
a key attribute cannot have NULL values.
Key constraints are also
referred to as Entity Constraints.
An entity set can have
multiple
A primary key can contain a keys, but out of which one key will be the
unique and null value in the relational table. primary ka
ID
NAME SEMESTER AGE
22UGCS01 MELVIN 18
22UGCS02 VENKAT 19
22UGCS03 WESLEY IV 21
22UGCS04 RAJESH
20
22UGCS02 VIKRAM III A

Not allowed since all row must be


unique
3.4
Relational Algebra Operations
Relationaldatabase systems are expected to be
assist its users to query the database equipped with a query language that can
instances.
There are two kinds of query languages -
relational algebra and relational calculus.
3.4.1 Relational Algebra
Relational algebrais a procedural query language, which
input and yields instances of takes instances of
relations as output. It uses operators to perform relations a
querieS.
Relational Database Management System 3.13
operator can be either unary or binary. They accept relations as their input and yield relations
as their output. Relational algebra is performed recursively on a relation and intermediate results
are also considered relations.
Thefundamental operations of relational algebra areas
follows
Select

Project
Union
Set different

Cartesian product
Rename
We will discuss all these operations in the
following sections.
Select Operation (o) - It selects tuples that satisfy the given
predicate from a relation.
Notation-or)
Where o stands for selection predicate and r stands for
formula which mayuse connectors like and, or, and not.relation.
p is prepositional logic
These terms may use relational
operators like - =,#,2,<, >, s.
For example,
Osubject "database"(Books)
Output -Selects tuples from books where subject is 'database!.
Osubject ="database"and price ="45so(Books)

Output -Selects tuples from books where subject is 'database' and 'price' is 450.
Osubject = "database" and price = "450" or year >"2010(Books)

Output -Selects tuples from books where subject is'database' and 'price' is 450 orthose
books published after 2010.
3.14 Relational Model

Project Operation (|) -It projects column(s) that satisfy a given predicate
Notation -IAl, A2, An (r)
Where Al, A2,An are attribute names of relationr.

Duplicate rows are automatically eliminated, as relation is a set.


For example,
Isubject, author (Books)
Selects and projects columns named as subject and
author from the relation Books
Union Operation (U) - It performs binary union
defined as,r Us= {t|tEror t¬ s} between two given relations and
Notation-rUs
Where r and s are either database
relations or relation result set (temporary
For a union operation to be relation)
valid, the following conditions must
be satisfied,
r, and smust have the 3
same number of attributes.
Attribute domains must be
compatible.
Duplicate tuples are automatically eliminated.
I| author (Books) U| author
(Articles)
Output - Projects the names of the
or both. authors who have either written a book or an artick
Set Difference (-) - The result of set difference
inone relation but are not in
thesecond relation. operation is tuples, which are presed
Notation -r-s
Finds allthe tuples that are
present in r but not in s.
I|uthor (Books)-I|author (Articles)
Output - Provides the name of
authors who have written books but not
articles.
Relational Database Munagement System 3.15

Cartesian Product(X) -Combincs information of twodifferent relations into one.


Notation X%

Whete r and&are ielalions and their outpul will be defined as

ovdka harctat3ooks Aticles)


(Output Yields arelalion, which shows allthe bocks and articles written by Charulatha
Authors.

kename Dperaton (p)- The reeills of relalional algetbra are also relations but without
Any n4ne The renAE opealion allows 46 l0 rename the Gulput relation,
'rename'
peation ia (denoted witlh annall (ireek letler tup,
Nitatlon p()
Where the Eul of expressn is haved witlh name of
341 ADDTONAL OPEMATO46
talended iferalon are those EaloR whnch can he derived fron basie operalurs.
Ihee afe nanly ihree lyes of Exended oEtalors in Melatnal Algebra.

DNT S6, ALL SOIS and tMI OYEE whieh are shewn in Table 1,
Tahle

You might also like