0% found this document useful (0 votes)
10 views16 pages

Database

The document outlines various database models, focusing on the relational model which organizes data in tables with defined structures and integrity constraints. It discusses the importance of primary and foreign keys to manage relationships and avoid redundancy, as well as the Entity-Relationship (ER) model for designing databases. Additionally, it explains entities, attributes, relationships, and provides a description of ER diagrams for visual representation.

Uploaded by

chicho creative
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)
10 views16 pages

Database

The document outlines various database models, focusing on the relational model which organizes data in tables with defined structures and integrity constraints. It discusses the importance of primary and foreign keys to manage relationships and avoid redundancy, as well as the Entity-Relationship (ER) model for designing databases. Additionally, it explains entities, attributes, relationships, and provides a description of ER diagrams for visual representation.

Uploaded by

chicho creative
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/ 16

DATABASE

Database Models
Database Models

 A database model defines the manner in which various files of a


database are linked together.
 Four commonly used database models/database structures are:-
I. hierarchical,
II. network,
III. relational,
IV. object-oriented.
Relational Model

 A Relational database allows the definition of data structures, storage


and retrieval operations and integrity constraints.
 data and relations between them are organized in tables.
 A table is a collection of records and each record in a table contains
the same fields.
 Properties of Relational Tables:
 Values Are Atomic
 Each Row is Unique
 Column Values Are of the Same Kind
 The Sequence of Columns is Insignificant
 The Sequence of Rows is Insignificant
 Each Column Has a Unique Name
CONT..

 Primary key
 Each table should have a primary key, which means a field whose
value is different for every record,
 For example student number for a students’ table.
 Information redundancy
situations trying to put the information we need in a single table
database causes a duplication of identical data.
 For example, if we add to our students’ table the information on who
is the reference secretary for each student, together with other
secretary’s information such as office telephone number, office room
and timetables, we get this table:
Information redundancy is not a problem by itself, but:
 storing several times the same information is a waste of computer
space
 whenever we need to update a repeated information (e.g. the
secretary changes office), we need to do a lot of changes;
 manually inserting the same information several times can lead to
typing (or copying & pasting) mistakes, which decrease the quality of
the database.
 In order to avoid this situation, it is a common procedure to split the
table into two distinct tables, one for the students and another one
for the secretaries. To each secretary we assign a unique code and to
each student we indicate the secretary’s code.
 Foreign key
When a field, which is not the primary key, is used in a relation with
another table this field is called foreign key.
One‐to‐many relation.
For the example of section the tables above are indicated in this way,
meaning that for each student there is exactly one secretary and for
each secretary there are many students. This relation is called many‐to‐
one relation.
The Entity-Relationship (ER)
Model
 The Entity-Relationship (ER) Model is a conceptual framework
used to represent and design databases by identifying entities, their
attributes, and the relationships between them. It provides a clear,
high-level structure of the data and how they are interconnected
 An entity is a real-world object, concept, or thing that can be
distinctly identified and stored in a database. Entities typically
represent objects that have data associated with them.
 Example: Employee, Product, Department, Customer.
Types of Entities

 Strong Entities:
These exist independently of other entities. For example, "Employee"
could be a strong entity
 Weak Entities:
These depend on a strong entity and cannot exist without it. For
example, "Dependent" in relation to an Employee might be a weak
entity because its existence depends on the Employee entity.
Attributes

 Attributes describe the properties or characteristics of an entity.


Each entity has a set of attributes that provide more information
about it.
 For an Employee entity, the attributes might include EmployeeID,
EmployeeName, DateOfBirth, and Salary
 For a Product entity, attributes might include ProductID,
ProductName, Price, and Manufacturer
Types of Attributes:
 Simple Attributes: Cannot be divided further (e.g., EmployeeID,
ProductID)
 Composite Attributes: Can be divided into smaller sub-parts (e.g.,
Address can be divided into Street, City, and ZIP code).
Cont..

 Derived Attributes: Can be calculated from other attributes (e.g.,


Age can be derived from DateOfBirth).
 Multi-valued Attributes: Can have more than one value (e.g.,
PhoneNumbers for an employee)
Relationships

 A relationship is an association between two or more entities. It


describes how entities are related to each other in the database.
 An Employee works in a Department.
 A Customer places an Order.
Types of Relationships:
 One-to-One (1:1): Each instance of one entity is associated with
only one instance of another entity.
Example: Each Person has only one Passport
Cont..

 One-to-Many (1:M): One entity instance can be associated with


multiple instances of another entity.
Example: A Manager can supervise many Employees, but each
Employee has only one Manager.
 Many-to-Many (M:N): Multiple instances of one entity can be
associated with multiple instances of another entity.
Example: Students enroll in multiple Courses, and each Course has
many Students.
Cardinality

 Cardinality defines the number of instances of one entity that can be


associated with instances of another entity. It is an important part of
defining relationships.
 One-to-One (1:1): A single instance in one entity is related to a
single instance in another entity.
 One-to-Many (1:M): One instance of an entity is related to many
instances of another entity.
 Many-to-Many (M:N): Many instances of one entity are related to
many instances of another entity
ER Diagram (ERD)

 An ER Diagram is a graphical representation of the Entity-


Relationship Model. It visually shows the entities, their attributes, and
the relationships between them. Common components of an ERD
include:
 Rectangles: Represent entities.

 Ovals: Represent attributes.


Cont..

 Diamonds: Represent relationships.

 Lines: Link entities to relationships, and entities to their attributes.

You might also like