Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

The Relational Data Model and Relational Database Constraints

The document provides an overview of the relational data model, emphasizing its structure through tables (relations) consisting of unique rows (tuples) and columns (attributes). It discusses key concepts such as primary and foreign keys, domain constraints, and the importance of entity and referential integrity in maintaining data accuracy and consistency. Additionally, it outlines the role of relational database schemas in organizing data and establishing relationships between tables.

Uploaded by

fadistyle34
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

The Relational Data Model and Relational Database Constraints

The document provides an overview of the relational data model, emphasizing its structure through tables (relations) consisting of unique rows (tuples) and columns (attributes). It discusses key concepts such as primary and foreign keys, domain constraints, and the importance of entity and referential integrity in maintaining data accuracy and consistency. Additionally, it outlines the role of relational database schemas in organizing data and establishing relationships between tables.

Uploaded by

fadistyle34
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

The Relational Data Model

and Relational Database


Constraints
Group Presentation
M.Sufyan
Asim Iqbal
Hassan Altaf
M. Shehzad
RELATIONAL MODEL
CONCEPTS
• The relational model is a framework for managing and organizing data using
tables (relations). Each table consists of rows (tuples) and columns (attributes). It
ensures data is structured logically and accessed efficiently. Key concepts include:
• Relation: A table with unique rows and columns.
• Attribute: A column in a table representing a data field.
• Tuple: A row in a table representing a single data entry.
• Primary Key: A unique identifier for table rows.
• Foreign Key: A reference to a primary key in another table to maintain
relationships.
• Domain: A set of allowable values for an attribute.
Domains, Attributes, Tuples,
and Relations
• A relation is a table with rows and columns that represents data. Here’s
how the core concepts fit in:
• Domain: The set of valid values for an attribute (e.g., "Age" can have
values between 1–120).
• Attribute: A column in a table, representing a specific property of the
data (e.g., "Name" or "Age").
• Tuple: A single row in a table, representing a single record (e.g., data
about one person).
• Relation: The entire table, a collection of tuples sharing the same
attributes.
Example Table
Characteristics of Relations
•Rows and Columns: A relation is represented as a table with rows
(tuples) and columns (attributes).
•Unique Rows: Each row in a relation is unique, ensuring no duplicate
tuples.
•Column Order Irrelevance: The order of columns does not matter in a
relation.
•Row Order Irrelevance: The order of rows does not affect the relation.
•Attribute Values: Each attribute contains atomic (indivisible) values
from its domain.
•Unique Attribute Names: Each column has a unique name within a
relation.
•Key Constraints: Every relation has a primary key to uniquely identify
tuples.
•Null Values: Attributes may have null values to represent missing or
unknown data.
Relational Model Notation
• Relational Model Notation is a way of representing the structure
of a relational database, specifically its tables and relationships,
in a standardized manner. Here’s how it works:
Relation: A table in a relational database is called a relation. A
relation is represented as a set of tuples (rows) with a fixed
number of attributes (columns). Each attribute in a relation has a
name, and the values of the attributes are the data elements. For
example, if you have a table for Employees, the relation might
look like this
RELATIONAL MODEL CONSTRAINTS
AND RELATIONAL DATABASE SCHEMAS

Relational model constraints are rules that the data


must follow to ensure data integrity, consistency,
and accuracy in a relational database. These
constraints are fundamental for defining the
relationships between tables and the rules
governing the data within the tables.
Domain Constraints
• Domain Constraints define the valid set of values that an attribute (column) can have in
a relational database. These constraints help maintain the integrity of data by ensuring
that only appropriate and valid data is entered into a column. Domain constraints are
particularly useful to enforce specific data types, value ranges, and formats.
• Example:
• Consider an Employee table with the following attributes:
• EmployeeID (Integer)
• Name (String)
• Age (Integer)
• Salary (Decimal)
• HireDate (Date)
Domain Constraints in Action
Key Constraints and
Constraints on Null Values
• 1. Key Constraints
• Key constraints ensure that each record (row) in a table can be uniquely
identified. The primary types of key constraints are:
• Primary Key (PK): A primary key is a unique identifier for each record in a
table. No two records can have the same value for the primary key attribute, and
it cannot have NULL values.
• Foreign Key (FK): A foreign key is an attribute (or set of attributes) in one
table that refers to the primary key in another table. It establishes a relationship
between two tables.
• Unique Key: Ensures that the values in a column (or set of columns) are unique
across all records, but unlike a primary key, it can accept NULL values.
Constraints on Null Values
• A NULL value represents missing or unknown data. Some
attributes allow NULL values (optional data), while others
do not (required data). NOT NULL constraints are used
to ensure that an attribute must have a value and cannot
be NULL.
Relational Databases
• A relational database is a type of database that stores data in
a structured format, using rows and columns within tables. The
fundamental concept behind a relational database is the use of
relationships between tables to organize and manage data.
These relationships are established through keys, such as
primary keys and foreign keys, which link data in different
tables
Example of RDBMS:
MySQL , PostgreSQL , Oracle , Database Microsoft SQL Server
Relational Database Schemas

• A relational database schema is the structure


that defines the organization of data within a
relational database. It consists of the tables, the
columns in those tables, and the relationships
between the tables. The schema outlines how data
is stored and connected, and it serves as a
blueprint for how the database is constructed
Entity Integrity
Entity Integrity is a fundamental concept in relational databases that
ensures
that every entity (or record) within a table is uniquely identifiable.
This is achieved
through the use of a Primary Key.
Primary Key (PK): A primary key is a column (or a set of columns) in
a table that
uniquely identifies each row in that table. The primary key ensures
that no two rows
in the table can have the same value in the primary key column(s).
The primary key must
be unique for each record, and it cannot have a NULL value.
For example:
In a Students table, the student_id could be the primary key, which
uniquely identifies each student.
Entity Integrity Rules
•Every table must have a primary key.
•The primary key must uniquely identify each
record.
•The primary key cannot contain NULL values
because a NULL value would violate
the uniqueness of the key.
Referential Integrity
• Referential Integrity ensures that relationships between
tables remain consistent. Specifically, it ensures that a foreign
key value in one table always refers to a valid primary key value
in another table (or within the same table).
• Foreign Key (FK): A foreign key is a column (or set of columns)
in one table that links to the primary key of another table. The
foreign key establishes a relationship between the two tables.
The value in the foreign key column must either be NULL or
must match an existing primary key value in the related table.
Referential Integrity Rules
•A foreign key in a child table must always reference an existing
primary key in the parent table.
•If a foreign key value exists, the corresponding primary key value
must exist in
the referenced table (i.e., you cannot have a foreign key pointing to
a non-existent record).
•If a primary key record is deleted or updated, the relational
database management system
(RDBMS) can enforce rules about how to handle the corresponding
foreign keys
(such as cascading updates or deletes)
Foreign Key
• A Foreign Key is a key used to link two tables together. It is a column (or a
combination of columns) that contains values that refer to the primary key
in another table, establishing a relationship between the two tables.
• Key Points about Foreign Keys:
• The foreign key column(s) in the child table refer to the primary key
column(s) in the parent table.
• A foreign key enforces referential integrity, ensuring that no child table
record can reference a non-existent record in the parent table.
• Foreign keys help define relationships such as one-to-many, many-to-one, or
many-to-many between tables

You might also like