0% found this document useful (0 votes)
3 views15 pages

Chapter 2

The document provides an overview of the Relational Data Model, explaining key concepts such as relations, entities, attributes, and relationships. It details various types of attributes, relationships, and constraints that govern data integrity within a relational database. Additionally, it discusses the importance of keys and views in managing and accessing data effectively.

Uploaded by

eliasferhan1992
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)
3 views15 pages

Chapter 2

The document provides an overview of the Relational Data Model, explaining key concepts such as relations, entities, attributes, and relationships. It details various types of attributes, relationships, and constraints that govern data integrity within a relational database. Additionally, it discusses the importance of keys and views in managing and accessing data effectively.

Uploaded by

eliasferhan1992
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/ 15

UNIT TWO

Relational Data Model

Relational Model (RM) represents the database as a collection of relations.


A relation is nothing but a table of values.
Every row in the table represents a collection of related data values.
These rows in the table denote a real-world entity or relationship.

Terminologies
 Tables=relation  Relationship(association)
 Degree of relation(number of entity types)
 Entities
 Cardinality of a relation(number of instances/tuples that can be
 Attribute
associated)
 Column=field  Constraints(rule)

 Tuple=row
Cont…

ENTITIES: The entities (persons, places, things etc.) which the organization has to deal with.

 The name given to an entity should always be a singular noun descriptive of each item to

be stored in it.

E.g.: student, NOT students.

ATTRIBUTES - The items of information which characterize and describe these entities.

 Attributes are pieces of information about entities.


Cont…

Types of Attributes
 Simple (atomic) Vs Composite attributes
 Simple: These are atomic values which cannot be divided into sub parts.
E.g. Age, gender, salary etc.

 Composite: Divided into sub parts (composed of other attributes).


E.g. Name, address etc.
Continue…

 Single-valued Vs multi-valued attributes


 Single-valued: Have only single value (the value may change but has only one value at one time).
E.g. Age, Sex, S-id. No, color_of_eyes, etc.

 Multi-Valued: Have more than one value.


E.g. Address, Mobile-number, Person may have several college degrees, etc.
Continue…
 Derived Vs Stored Attributes
 Derived: The value may be derived (computed) from the values of other attributes. The attribute do not exist in the
physical database.
E.g. Age (current year – date of birth).
Length of employment (current date- start date).
Profit (earning-cost).
G.P.A (grade point/credit hours).
 Stored: not possible to derive or compute.
E.g. Date of Birth.
Null Values
 NULL applies to attributes which are not applicable or which do not have values.
 You may enter the value NA (meaning not applicable).
 Value of a key attribute cannot be null.
Continue…

RELATIONSHIPS: The relationships between entities which exist and must be taken into account when processing

information.

 The number of entities and the number of tuples participating in the association. These two concepts are

called degree and cardinality of a relationship respectively.

Degree of a Relationship: The number of entities participating in a relationship.

• Unary/recursive relationship: Tuples/records of a Single entity are related with each other.
Continue…

• Binary relationships: Tuples/records of two entities are associated in a relationship.

• Ternary relationship: Tuples/records of three different entities are associated.


Continue…

• n-ary relationship: Tuples from arbitrary number of entity sets are participating in a relationship.
Continue…

Cardinality of a Relationship: is the number of instances/tuples that can be associated with a single instance from one
entity in a single relationship.
 The number of instances participating or associated with a single instance from an entity in a relationship is called the
cardinality of the relationship.
The major cardinalities of a relationship are:
 One-to-one: one tuple is associated with only one other tuple.
o E.g. Building -to- Location
 One-to-many: one tuple can be associated with many other tuples, but not the reverse.
o E.g. Department-to-Student
• Many-to-one: many tuples are associated with one tuple but not the reverse.
o E.g. Employee–to-Department
 Many-to-many: one tuple is associated with many other tuples and from the other side, with a different role name one
tuple will be associated with many tuples.
o E.g. Student–to-Course
Relational Constraints
A constraint is a rule that is used for optimization purposes.
Constraints can be categorized:

 A NOT NULL constraint is a rule that prevents null values from being entered into one or more columns within a table.

 The DEFAULT constraint is used to set a default value for a column. The default value will be added to all new
records, if no other value is specified.
 A unique constraint (also referred to as a unique key constraint) is a rule that forbids duplicate values in one or more
columns within a table. we can save a null value, but, only one NULL value is supported.

 A primary key constraint is a column or combination of columns that has the same properties as a unique constraint. In the
case of a primary key, we cannot save NULL values.

 A foreign key constraint (also referred to as a referential constraint or a referential integrity constraint) is a logical rule
about values in one or more columns in one or more tables.

 A table check constraint (also called a check constraint) sets restrictions on data that is added to a specific table.
Relational Integrity

Types of Relational Integrity:

 Domain integrity: No value of the attribute should be beyond the allowable limits.

 Entity integrity: In a base relation, no attribute of a Primary Key can assume a value of NULL.

 Referential integrity: If a Foreign Key exists in a relation, either the Foreign Key value must match a

Candidate Key value in its home relation or the Foreign Key value must be NULL.

 Enterprise integrity: Additional rules specified by the users or database administrators of a database are

incorporated.
Key Constraints

 A key refers to an attribute/a set of attributes that help us identify a row (or tuple) uniquely in a table (or relation).

 A key is also used to establish relationship between the different columns and tables of a relational database.

Types of Keys:
A super key: A super key also known as super set is then a set of one or more attributes that in group (collectively) can identify an
entity uniquely from the entity set.
Example: “EMPLOYEES” entity set (“EmpId”, “EmpId, Name”, “NationalId”, “NationalId, BDate”)
Candidate Key: an attribute or set of attributes that uniquely identifies individual occurrences of an entity type or tuple within a
relation.
A candidate key has two properties:
• Uniqueness
• Irreducibility

Alternate key: is a candidate key that are not selected as primary key are called Alternate key.

Primary key: the candidate key that is selected to identify tuples uniquely within the relation.

Foreign key: an attribute, or set of attributes, within one relation that matches the candidate key of some relation
Referential Constraint
Relational language and Views

 Relations are perceived as a table from the users’ perspective.

 The two categories or types of relations are Base (Named) and View (Unnamed) Relations.

Base (Named Relation): A named relation corresponding to an entity in the conceptual schema, whose tuples

are physically stored in the database.

View (Unnamed Relation): A View is the dynamic result of one or more relational operations operating on the

base relations to produce another virtual relation that does not actually exist as presented.
Cont…

Purpose of a view

 Hides unnecessary information from users

 Provide powerful flexibility and security

 Provide customized view of the database for users

 A view of one base relation can be updated.

 Update on views derived from various relations is not allowed since it may violate the integrity of the

database.

 Update on view with aggregation and summary is not allowed.

You might also like