Escolar Documentos
Profissional Documentos
Cultura Documentos
data and how it is related. Data and relationships are represented in a fat,
two-dimensional table that preserves relational structuring.[1]
A Relational Database anagement !"stem #RD$!% is the ph"sical and
logical implementation of a relational database #hardware and software%. An
RD! controls reading, writing, modif"ing, and processing the information
stored in the databases. &he data is formall" described and organi'ed
according to each database(s relational model #database schema%, according
to the design.
Relational databases tend to be either signi)cantl" normali'ed or de-
normali'ed. *ormali'ed databases #operational databases% tend to have
better data integrit", reduced storage space, and faster transmissions.
Databases are de-normali'ed to improve performance, often for reporting and
decision-ma+ing applications #larger trend anal"sis%. De-normali'ed
databases ma" form data marts and warehouses. ost data warehouses have
an operational database that is used to produce the datamarts.[,][-] #!ee
*ormali'ation below.%
Relational databases displaced hierarchical databases because the abilit" to
add new relations made it possible to add new information that was valuable
but .bro+e. a non-relational database(s hierarchical conception. &he trend
continues as a networ+ed planet and social media create the world of .big
data. which is larger and less structured than the datasets and tas+s that
relational databases handle well #it is instructive to compare
/adoop%.0verview[edit]
1ach database is a collection of related tables. 1ach table is a ph"sical
representation of an entit" or ob2ect that is in a tabular format consisting of
columns and rows. 3olumns are the )elds of a record or the attributes of an
entit". &he rows contain the values or data instances4 these are also called
records or tuples.
Relationships e5ist both among the columns within a table and among the
tables. &hese relationships ta+e three logical forms6 one-to-one, one-to-man",
or man"-to-man". ost relational databases are designed so there is onl" one
value per cell #an intersection of a column and row%4 in this design pattern,
there are onl" one-to-one relationships within a table. 1ach table is named
according to the data it contains, such as people or addresses.
7n order for a D$! to operate e8cientl" and accuratel", it must have A37D
transactions.[9][:][;] <art of this processing involves consistentl" being able
to select or modif" one and onl" one row in a table. &herefore, most ph"sical
implementations have a s"stem-assigned, uni=ue primar" +e" for each table.
>hen a new row is written to the table, the s"stem generates and writes the
new, uni=ue value for the primar" +e" #<?%4 this is the +e" that the s"stem
uses primaril" for accessing the table. !"stem performance is optimi'ed for
<?s. 0ther, more natural +e"s ma" also be identi)ed and de)ned as alternate
+e"s #A?%. 0ften several columns ma" be needed to form an A? #this is one
reason wh" a single integer column is usuall" made the <?%. $oth <?s and
A?s have the abilit" to uni=uel" identif" one row within a table. Additional
technolog" ma" be applied that will signi)cantl" assure a uni=ue 7D across
the world, a globall" uni=ue identi)er4 these are used when there are broader
s"stem re=uirements.
&he primar" +e"s within a database are used to de)ne the relationships
among the tables. >hen a <? migrates to another table, it becomes a foreign
+e" in the other table. >hen each cell can contain onl" one value and the <?
migrates into a regular entit" table, this design pattern can represent either a
one-to-one, or a one-to-man" relationship. ost relational database designs
resolve man"-to-man" relationships b" creating an additional table that
contains the <?s from both of the other entit" tables@the relationship
becomes an entit"4 the resolution table is then named appropriatel" and is
often assigned its own <? while the two A?s are combined to form an A?. &he
migration of <?s to other tables is the second ma2or reason wh" s"stem-
assigned integers are used normall" as <?s4 there usuall" is neither e8cienc"
nor clarit" in migrating a bunch of other t"pes of columns.
ost of the programming within a RD$! is accomplished using stored
procedures #!<s%. 0ften procedures can be used to greatl" reduce the amount
of information transferred within and outside of a s"stem. Aor increased
securit", the s"stem design ma" also grant access to onl" the stored
procedures and not directl" to the tables. Aundamental stored procedures
contain the logic needed to insert new data and update e5isting data. ore
comple5 procedures ma" be written to implement additional rules and logic
related to processing or selecting the data.
&erminolog"[edit]
Relational database terminolog".
&he relational database was )rst de)ned in Bune 1CDE b" 1dgar 3odd, of
7$(s !an Bose Research Faborator".[D] 3odd(s view of what =uali)es as an
RD$! is summari'ed in 3odd(s 1, rules. A relational database has become
the predominant choice in storing data. 0ther models besides the relational
model include the hierarchical database model and the networ+ model.
&he table below summari'es some of the most important relational database
terms and their !GF e=uivalents.
!GF term Relational database term Description
Row &uple or record A data set representing a single item
3olumn Attribute or )eld A labeled element of a tuple, e.g. .Address.
or .Date of birth.
&able Relation or $ase relvar A set of tuples sharing the same attributes4 a
set of columns and rows
Hiew or result set Derived relvar An" set of tuples4 a data report from
the RD$! in response to a =uer"
Relations or &ables[edit]
ain articles6 Relation #database% and &able #database%
A relation is de)ned as a set of tuples that have the same attributes. A tuple
usuall" represents an ob2ect and information about that ob2ect. 0b2ects are
t"picall" ph"sical ob2ects or concepts. A relation is usuall" described as a
table, which is organi'ed into rows and columns. All the data referenced b"
an attribute are in the same domain and conform to the same constraints.
&he relational model speci)es that the tuples of a relation have no speci)c
order and that the tuples, in turn, impose no order on the attributes.
Applications access data b" specif"ing =ueries, which use operations such as
select to identif" tuples, pro2ect to identif" attributes, and 2oin to combine
relations. Relations can be modi)ed using the insert, delete, and update
operators. *ew tuples can suppl" e5plicit values or be derived from a =uer".
!imilarl", =ueries identif" tuples for updating or deleting.
&uples b" de)nition are uni=ue. 7f the tuple contains a candidate or primar"
+e" then obviousl" it is uni=ue4 however, a primar" +e" need not be de)ned
for a row or record to be a tuple. &he de)nition of a tuple re=uires that it be
uni=ue, but does not re=uire a primar" +e" to be de)ned. $ecause a tuple is
uni=ue, its attributes b" de)nition constitute a super+e".
$ase and derived relations[edit]
ain articles6 Relvar and Hiew #database%
7n a relational database, all data are stored and accessed via relations.
Relations that store data are called .base relations., and in implementations
are called .tables.. 0ther relations do not store data, but are computed b"
appl"ing relational operations to other relations. &hese relations are
sometimes called .derived relations.. 7n implementations these are called
.views. or .=ueries.. Derived relations are convenient in that the" act as a
single relation, even though the" ma" grab information from several
relations. Also, derived relations can be used as an abstraction la"er.
Domain[edit]
ain article6 data domain
A domain describes the set of possible values for a given attribute, and can
be considered a constraint on the value of the attribute. athematicall",
attaching a domain to an attribute means that an" value for the attribute
must be an element of the speci)ed set. &he character string .A$3., for
instance, is not in the integer domain, but the integer value 1,- is.
3onstraints[edit]
3onstraints ma+e it possible to further restrict the domain of an attribute. Aor
instance, a constraint can restrict a given integer attribute to values between
1 and 1E. 3onstraints provide one method of implementing business rules in
the database. !GF implements constraint functionalit" in the form of chec+
constraints. 3onstraints restrict the data that can be stored in relations.
&hese are usuall" de)ned using e5pressions that result in a boolean value,
indicating whether or not the data satis)es the constraint. 3onstraints can
appl" to single attributes, to a tuple #restricting combinations of attributes% or
to an entire relation. !ince ever" attribute has an associated domain, there
are constraints #domain constraints%. &he two principal rules for the relational
model are +nown as entit" integrit" and referential integrit".
<rimar" +e"[edit]
ain article6 Ini=ue +e"
A primar" +e" uni=uel" speci)es a tuple within a table. 7n order for an
attribute to be a good primar" +e" it must not repeat. >hile natural attributes
#attributes used to describe the data being entered% are sometimes good
primar" +e"s, surrogate +e"s are often used instead. A surrogate +e" is an
arti)cial attribute assigned to an ob2ect which uni=uel" identi)es it #for
instance, in a table of information about students at a school the" might all
be assigned a student 7D in order to diJerentiate them%. &he surrogate +e"
has no intrinsic #inherent% meaning, but rather is useful through its abilit" to
uni=uel" identif" a tuple. Another common occurrence, especiall" in regard to
*6 cardinalit" is the composite +e". A composite +e" is a +e" made up of two
or more attributes within a table that #together% uni=uel" identif" a record.
#Aor e5ample, in a database relating students, teachers, and classes. 3lasses
could be uni=uel" identi)ed b" a composite +e" of their room number and
time slot, since no other class could have e5actl" the same combination of
attributes. 7n fact, use of a composite +e" such as this can be a form of data
veri)cation, albeit a wea+ one.
Aoreign +e"[edit]
ain article6 Aoreign +e"
A foreign +e" is a )eld in a relational table that matches the primar" +e"
column of another table. &he foreign +e" can be used to cross-reference
tables. Aoreign +e"s need not have uni=ue values in the referencing relation.
Aoreign +e"s eJectivel" use the values of attributes in the referenced relation
to restrict the domain of one or more attributes in the referencing relation. A
foreign +e" could be described formall" as6 .Aor all tuples in the referencing
relation pro2ected over the referencing attributes, there must e5ist a tuple in
the referenced relation pro2ected over those same attributes such that the
values in each of the referencing attributes match the corresponding values
in the referenced attributes..
!tored procedures[edit]
ain article6 !tored procedure
A stored procedure is e5ecutable code that is associated with, and generall"
stored in, the database. !tored procedures usuall" collect and customi'e
common operations, li+e inserting a tuple into a relation, gathering statistical
information about usage patterns, or encapsulating comple5 business logic
and calculations. Are=uentl" the" are used as an application programming
interface #A<7% for securit" or simplicit". 7mplementations of stored procedures
on !GF RD$!s often allow developers to ta+e advantage of procedural
e5tensions #often vendor-speci)c% to the standard declarative !GF s"nta5.
!tored procedures are not part of the relational database model, but all
commercial implementations include them.
7nde5[edit]
ain article6 7nde5 #database%
An inde5 is one wa" of providing =uic+er access to data. 7ndices can be
created on an" combination of attributes on a relation. Gueries that )lter
using those attributes can )nd matching tuples randoml" using the inde5,
without having to chec+ each tuple in turn. &his is analogous to using the
inde5 of a boo+ to go directl" to the page on which the information "ou are
loo+ing for is found, so that "ou do not have to read the entire boo+ to )nd
what "ou are loo+ing for. Relational databases t"picall" suppl" multiple
inde5ing techni=ues, each of which is optimal for some combination of data
distribution, relation si'e, and t"pical access pattern. 7ndices are usuall"
implemented via $K trees, R-trees, and bitmaps. 7ndices are usuall" not
considered part of the database, as the" are considered an implementation
detail, though indices are usuall" maintained b" the same group that
maintains the other parts of the database. 7t should be noted that use of
e8cient inde5es on both primar" and foreign +e"s can dramaticall" improve
=uer" performance. &his is because $-tree inde5es result in =uer" times
proportional to log#n% where n is the number of rows in a table and hash
inde5es result in constant time =ueries #no si'e dependenc" so long as the
relevant part of the inde5 )ts into memor"%.
Relational operations[edit]
ain article6 Relational algebra
Gueries made against the relational database, and the derived relvars in the
database are e5pressed in a relational calculus or a relational algebra. 7n his
original relational algebra, 3odd introduced eight relational operators in two
groups of four operators each. &he )rst four operators were based on the
traditional mathematical set operations6
&he union operator combines the tuples of two relations and removes all
duplicate tuples from the result. &he relational union operator is e=uivalent to
the !GF I*70* operator.
&he intersection operator produces the set of tuples that two relations share
in common. 7ntersection is implemented in !GF in the form of the 7*&1R!13&
operator.
&he diJerence operator acts on two relations and produces the set of tuples
from the )rst relation that do not e5ist in the second relation. DiJerence is
implemented in !GF in the form of the 1L31<& or 7*I! operator.
&he cartesian product of two relations is a 2oin that is not restricted b" an"
criteria, resulting in ever" tuple of the )rst relation being matched with ever"
tuple of the second relation. &he cartesian product is implemented in !GF as
the 3R0!! B07* operator.
&he remaining operators proposed b" 3odd involve special operations speci)c
to relational databases6
&he selection, or restriction, operation retrieves tuples from a relation,
limiting the results to onl" those that meet a speci)c criterion, i.e. a subset in
terms of set theor". &he !GF e=uivalent of selection is the !1F13& =uer"
statement with a >/1R1 clause.
&he pro2ection operation e5tracts onl" the speci)ed attributes from a tuple or
set of tuples.
&he 2oin operation de)ned for relational databases is often referred to as a
natural 2oin. 7n this t"pe of 2oin, two relations are connected b" their common
attributes. !GF(s appro5imation of a natural 2oin is the 7**1R B07* operator. 7n
!GF, an 7**1R B07* prevents a cartesian product from occurring when there
are two tables in a =uer". Aor each table added to a !GF Guer", one
additional 7**1R B07* is added to prevent a cartesian product. &hus, for *
tables in a !GF =uer", there must be *-1 7**1R B07*! to prevent a cartesian
product.
&he relational division operation is a slightl" more comple5 operation, which
involves essentiall" using the tuples of one relation #the dividend% to partition
a second relation #the divisor%. &he relational division operator is eJectivel"
the opposite of the cartesian product operator #hence the name%.
0ther operators have been introduced or proposed since 3odd(s introduction
of the original eight including relational comparison operators and e5tensions
that oJer support for nesting and hierarchical data, among others.
*ormali'ation[edit]
ain article6 Database normali'ation
*ormali'ation was )rst proposed b" 3odd as an integral part of the relational
model. 7t encompasses a set of procedures designed to eliminate nonsimple
domains #non-atomic values% and the redundanc" #duplication% of data, which
in turn prevents data manipulation anomalies and loss of data integrit". &he
most common forms of normali'ation applied to databases are called the
normal forms.