0% found this document useful (0 votes)
26 views22 pages

1.relational Model Concepts

The document discusses key concepts of the relational model including relations, attributes, domains, tuples, and relation schemas. A relation represents a table of values made up of rows and columns. Attributes specify the interpretation of values in each column. Tuples represent individual records in a relation.

Uploaded by

Sujal Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views22 pages

1.relational Model Concepts

The document discusses key concepts of the relational model including relations, attributes, domains, tuples, and relation schemas. A relation represents a table of values made up of rows and columns. Attributes specify the interpretation of values in each column. Tuples represent individual records in a relation.

Uploaded by

Sujal Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Relational Model

Concepts
 The relational model represents the database as a
collection of relations.

 Informally, each relation resembles a table of values


or, to some extent, a flat file of records.
 It is called a flat file because each record has a simple
linear or flat structure.
 When a relation is thought of as a table of values,
◦ each row in the table represents a collection of related data
values.
 A row represents a fact that typically
corresponds to a real-world entity or
relationship.
 The table name and column names are used to
help to interpret the meaning of the values in
each row.

 The column names—Name, Student_number,


Class, and Major—specify how to interpret the
data values in each row, based on the column
each value is in.
 All values in a column are of the same data type.
 In the formal relational model terminology,
◦ a row is called a tuple,
◦ a column header is called an attribute, and
◦ the table is called a relation.

 The data type describing the types of values that can


appear in each column is represented by a domain of
possible values.
Domains, Attributes,
Tuples, and Relations
Domains, Attributes, Tuples, and Relations
 A domain D is a set of atomic values.
◦ Atomic - each value in the domain is indivisible .

 A common method of specifying a domain is


◦ to specify a data type from which the data values forming the
domain are drawn.
 It is also useful to specify a name for the domain, to help in
interpreting its values.
 A domain is thus given a
◦ name, data type, and format
 Usa_phone_numbers.
◦ The set of ten-digit phone numbers valid in the
United States.
 Local_phone_numbers.
◦ The set of seven-digit phone numbers valid
within a particular area code in the United States.
 Social_security_numbers.
◦ The set of valid nine-digit Social Security
numbers.
◦ (This is a unique identifier assigned to each
person in the United States for employment, tax,
and benefits purposes.)
 Names:
◦ The set of character strings that represent names
of persons.
 Grade_point_averages.
◦ Possible values of computed grade point
averages; each must be a real (floating-point)
number between 0 and 4.
 Employee_ages.
◦ Possible ages of employees in a company; each
must be an integer value between 15 and 80.
 Academic_department_names.
◦ The set of academic department names in a
university, such as Computer Science, Economics,
and Physics.
 Academic_department_codes.
◦ The set of academic department codes, such as
‘CS’, ‘ECON’, and ‘PHYS’.
 A relation schema R, denoted by
R(A1,A2,...,An), is made up of
◦ a relation name R and
◦ a list of attributes, A1,A2, ...,An.
 Each attribute Ai is the name of a role played by
some domain D in the relation schema R.
 D is called the domain of Ai and is denoted by
dom(Ai).
 A relation schema is used to describe a relation; R
is called the name of this relation.
 The degree(or arity) of a relation is the number of
attributes n of its relation schema.
 A relation of degree seven, which stores
information about university students, would
contain seven attributes describing each
student as follows:
◦ STUDENT(Name, Ssn, Home_phone, Address,
Office_phone, Age, Gpa)
 Using the data type of each attribute, the
definition is sometimes written as:
◦ STUDENT(Name: string, Ssn : string, Home_phone :
string, Address : string, Office_phone : string, Age :
integer, Gpa : real)
 For this relation schema,
 STUDENT is the name of the relation, which

has seven attributes.


 STUDENT relation : dom(Name) = Names,

dom(Ssn) = Social_security_numbers ,
dom(HomePhone) = USA_phone_numbers ,
dom(Office_phone) = USA_phone_numbers,
and dom(Gpa) = Grade_point_averages.
 A relation (or relation state) r of the relation
schema R(A1, A2, ..., An), denoted by r(R),
◦ is a set of n-tuples r= {t1,t2, ...,tm}.

 Each n-tuple t is an ordered list of n values


t=<v1,v2, ..., vn>, where each value vi, 1≤i ≤n, is an
element of dom(Ai) or is a special NULL value.
 The ith value in tuple t, which corresponds to the
attribute Ai, is referred to as t[Ai] or t.Ai
 Relation Schema R is known as relation
intension
 Relation state r(R) is known as relation

extension.
 Eg: STUDENT relation, which corresponds to
the STUDENT schema.
 Each tuple in the relation represents a

particular student entity (or object).


 The relation is displayed as a table , where

each tuple is shown as a row and each


attribute corresponds to a column header
indicating a role or interpretation of the
values in that column.
 NULL values represent attributes whose
values are unknown or do not exist for some
individual STUDENT tuple.
The attributes and tuples of a
relation STUDENT.
Relational Model
Notation
Relational Model Notation
 A relation schema R of degree n is denoted
by R(A1,A2, ...,An).
◦ The uppercase letters Q,R,S denote relation names.
◦ The lowercase letters q,r,s denote relation states.
◦ The letters t,u,v denote tuples.
 In general,
◦ the name of a relation schema such as STUDENT
also indicates the current set of tuples in that
relation—the current relation state—whereas
STUDENT(Name, Ssn, ...) refers only to the relation
schema.
 An attribute A can be qualified with the
relation name R to which it belongs by using
the dot notation R.A—for example,
STUDENT.Name or STUDENT.Age.
 This is because the same name may be used

for two attributes in different relations.


However, all attribute names in a particular
relation must be distinct.
 An n-tuple t in a relation r(R) is denoted by
t= <v1,v2, ...,vn>, where vi is the value
corresponding to attribute Ai.
 The following notation refers to component
values of tuples:
◦ Both t[Ai] and t.Ai (and sometimes t[i]) refer to the
value vi in t for attribute Ai.
◦ Both t[Au, Aw, ..., Az] and t.(Au, Aw, ..., Az), where Au,
Aw, ..., Az is a list of attributes from R, refer to the
subtuple of values <vu,vw, ...,vz> from t
corresponding to the attributes specified in the list.
 the tuple t= <‘Barbara Benson’, ‘533-69-
1238’, ‘(817)839-8461’, ‘7384 Fontana
Lane’,NULL, 19, 3.25>
 t[Name] = <‘Barbara Benson’>,

t[Ssn,Gpa,Age] = <‘533-69-1238’,3.25, 19>.

You might also like