0% found this document useful (0 votes)
64 views11 pages

Structure of Relational Model

rdms fdata bse system
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)
64 views11 pages

Structure of Relational Model

rdms fdata bse system
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/ 11

Madhav

Institute
of
Technology

Database Management System &


Science
Gwalior (M.P.)
(Deemed
University)

By

Prof. Ramnaresh Sharma


Assistant Professor
Centre for Artificial Intelligence
Structure of Relational Model:
The structure of a relational database is designed to store, organize, and manage Madhav
Institute
data using a collection of related tables. Each table in a relational database holds of
data about a specific entity, and relationships between these entities are Technology
&
established through keys. Below is the structure of a relational database: Science
Gwalior (M.P.)
1. Tables (Relations): (Deemed
•Definition: The core components of a relational database are tables. Each table University)

represents a specific entity (e.g., "Customers", "Orders", "Products").


•Structure: Tables are organized into rows and columns, where each row
corresponds to a single record, and each column corresponds to an attribute of
that entity.
•Example: A "Customers" table might include columns like CustomerID, Name,
Address, and PhoneNumber.
Structure of Relational Model:
Columns (Attributes or Fields):
•Definition: Columns define the type of data stored in the table. Each column has
a name and a data type (e.g., INTEGER, VARCHAR, DATE).
•Role: Columns are the properties or attributes of the entity that the table
represents.
•Example: In a "Products" table, columns could include ProductID,
ProductName, Price, and StockQuantity.

3. Rows (Records or Tuples):


•Definition: Each row in a table represents a single, unique record or instance of
the entity described by the table.
•Example: A row in a "Customers" table might represent a specific customer,
with values in each column corresponding to that customer's details (e.g., 1, "John
Doe", "123 Main St", "555-1234").
Structure of Relational Model:
Primary Key:
•Definition: A primary key is a unique identifier for each record in a table. It ensures that
each row can be uniquely identified.
•Role: The primary key column (or combination of columns) must have unique values for
each row and cannot contain NULL values.
•Example: CustomerID in a "Customers" table might be the primary key, ensuring that no
two customers have the same CustomerID.

5. Foreign Key:
•Definition: A foreign key is a column (or set of columns) in one table that establishes a
link to the primary key in another table.
•Role: Foreign keys create relationships between tables, enabling the relational aspect of
the database.
•Example: An OrderID column in an "OrderItems" table might be a foreign key that links
to the OrderID primary key in an "Orders" table.
Structure of Relational Model:
Indexes:
•Definition: Indexes are special database objects that improve the speed of data retrieval
operations on a table.
•Role: Indexes help the database quickly locate data without having to scan every row in a
table.
•Example: An index on the CustomerID column in the "Customers" table would speed up
queries searching for a customer by their ID.
7. Relationships:
•One-to-One: A single row in one table is associated with a single row in another table.
•One-to-Many: A single row in one table is associated with multiple rows in another table.
•Many-to-Many: Multiple rows in one table are associated with multiple rows in another
table, typically managed through a junction table.
•Example: In an "Orders" table, a CustomerID foreign key might establish a one-to-many
relationship with the "Customers" table, indicating that each customer can place multiple
orders.
Structure of Relational Model:
• Schemas:
• Definition: A schema is a logical container for database objects like tables, views, andMadhav
Institute
indexes. of
Technology
• Role: Schemas help organize and group related objects within the database, often &
Science
reflecting different areas or modules of the application. Gwalior (M.P.)
(Deemed
• Example: A database for an e-commerce platform might have schemas for "Sales", University)
"Inventory", and "CustomerService".
• 9. Constraints:
• Not Null: Ensures that a column cannot have NULL (empty) values.
• Unique: Ensures that all values in a column are unique across rows.
• Check: Ensures that all values in a column meet a specific condition.
• Default: Automatically assigns a default value to a column if no value is provided.
• Foreign Key Constraint: Ensures referential integrity by restricting actions that
would break links between tables.
Structure of Relational Model:

•Relationships:
Madhav
•Relationships define the associations or interactions between entities. For example, a Institute
of
Student enrolls in a Course. Technology
•Relationship Set: A collection of similar relationships. For instance, the set of all &
Science
instances where students enroll in courses. Gwalior (M.P.)
(Deemed
•Degree of Relationship: University)

•The degree refers to the number of entities involved in a relationship.


•Unary (1-degree): A relationship involving one entity set (e.g., an employee
supervises themselves).
•Binary (2-degree): Involves two entity sets (e.g., Student enrolls in Course).
•Ternary (3-degree): Involves three entity sets (e.g., a Doctor treats a Patient using a
Medication).
Structure of Relational Model:
Cardinality:
• Specifies the number of instances of one entity that can be
associated with instances of another entity.
– One-to-One (1:1): Each entity in the relationship will have exactly one
related entity.
– One-to-Many (1
– ): An entity on one side of the relationship can be related to many entities
on the other side.
– Many-to-One (M:1): Many entities on one side of the relationship are
related to a single entity on the other side.
– Many-to-Many (M
– ): Entities on both sides of the relationship can have multiple related
entities.
Structure
• Views: of Relational Model:
• Definition: A view is a virtual table that is based on the result of a
Madhav
SELECT query. Institute
of
• Role: Views allow users to simplify complex queries, present data Technology
differently, or restrict access to specific rows or columns. &
Science
• Example: A view might join the "Customers" and "Orders" tables to Gwalior (M.P.)
(Deemed
show a report of customer orders. University)

• 11. Stored Procedures and Functions:


• Definition: Stored procedures are precompiled SQL code that can be
executed as a single unit, and functions are similar but often return a
value.
• Role: These help automate tasks, enforce business logic, and
encapsulate complex operations.
• Example: A stored procedure might automatically calculate and apply
discounts to orders above a certain amount.
Structure of Relational Model:
• Triggers:
• Definition: Triggers are special procedures that automatically execute in Madhav Institute
of
response to certain events on a table (like INSERT, UPDATE, DELETE). Technology
&
• Role: Triggers are used for enforcing complex business rules, auditing changes, Science
Gwalior (M.P.)
and maintaining derived data. (Deemed
University)
• Example: A trigger might update the "LastUpdated" timestamp column in a
table whenever a record is modified.
–.
Madhav
Institute
of
Technology
&

Thank You
Science
Gwalior (M.P.)
(Deemed
University)

You might also like