You are on page 1of 53

DATABASE MANAGEMENT

SYSTEMS (DBMS)
LEARNING OBJECTIVES:
Database design concepts
Key concepts in DBMS
Distinguish use of data types for fields

ENTITIES,
RELATIONSHIPS

AND
ATTRIBUTES
Entity, entity set, and
entity type
Entity

is an object in the real world with an independent existence that


can be differentiated from other objects. An entity might be
An object with physical existence (e.g., a lecturer, a
student, a car)
An object with conceptual existence (e.g., a course, a job,
a position)
Entity, entity set, and
entity type
Entity Type

The entity type is a collection of the entity having similar


attributes.
The E-R representation of the above Student Entity Type
is done below.

Note: We use a rectangle to represent an entity type in the E-


R diagram, not entity.
Entity, entity set, and
entity type
Entity Type

Types of Entity type


Strong Entity Type - re those entity types which has a
key attribute. The primary key helps in identifying each
entity uniquely. It is represented by a rectangle.
Weak Entity Type - doesn't have a key attribute. Weak
entity type can't be identified on its own. It depends
upon some other strong entity for its distinct identity.
In the previous example, Roll_no identifies each element of the
table uniquely and hence, we can say that STUDENT is a strong
entity type.
If we have two tables of Customer(Customer_id, Name, Mobile_no, Age, Gender) and
Address(Locality, Town, State, Customer_id). Here we cannot identify the address
uniquely as there can be many customers from the same locality. So, for this, we
need an attribute of Strong Entity Type i.e ‘Customer’ here to uniquely identify
entities of 'Address' Entity Type.
Entity, entity set, and
entity type
Entity Set

Entity Set is a collection of entities of the same entity type.


In the previous example of STUDENT entity type, a
collection of entities from the Student entity type would
form an entity set. We can say that entity type is a
superset of the entity set as all the entities are included in
the entity type. Let's try to understand this with the help
of an example.
Example 1: In the below example, two entities E1 (2, Angel, 19, 8709054568) and
E2(4, Analisa, 21, 9847852156) form an entity set.
Example 2: We can form another entity set by taking three entities from the table.
(2, Angel, 19, 8709054568) , (3, Priya, 20, 9864257315) and (4, Analisa, 21,
9847852156) can also form a entity set. Similary, we can form any combination of
the entity set using any of the entities from the entity type 'STUDENT'. Also, we can
understand that if we take all the records to the entity set we get the entity type
'STUDENT'. So, we can say that the entity type is the superset of the entity set.
RELATIONSHIPS
THEY ARE USED TO CONNECT RELATED
INFORMATION BETWEEN TABLES.

SIMILAR TO THE CASE OF ENTITY TYPES


AND ENTITY SETS, A RELATIONSHIP
TYPE AND ITS CORRESPONDING
RELATIONSHIP SET ARE CUSTOMARILY
REFERRED TO BY THE SAME NAME, R.

ENTITIES TAKE PART IN THE


RELATIONSHIP
Relationship Strength
it is based on how the priumary key of a related entity is defined

WEAK OR NON-IDENTIFYING RELATIONSHIPS


exists if the primary
key of the related
entity does not
contain a primary key
component of the
parent entity.
Relationship Strength
it is based on how the priumary key of a related entity is defined

STRONG OR IDENTIFYING RELATIONSHIPS


exists when the
primary key of the
related entity contains
the primary key
component of the
parent entity
Types of Relationships

One to one (1:1) One to many (1:M)


Relationship Relationship
Definition Definition

the relationship of one entity to only A one to many (1:M) relationship should
one other entity, and vice versa. be the norm in any relational database
it could indicate that two entities design and is found in all relational
actually belong in the same table. database environments.

FOR A MANY TO MANY RELATIONSHIP, CONSIDER THE


FOLLOWING POINTS:
• It cannot be implemented as such in the relational model.
• It can be changed into two 1:M relationships.
• It can be implemented by breaking up to produce a set of 1:M
relationships.
Many to many • It involves the implementation of a composite entity.
• Creates two or more 1:M relationships.
(M:M) • The composite entity table must contain at least the primary keys of
Relationship the original tables.
• The linking table contains multiple occurrences of the foreign key
values.
• Additional attributes may be assigned as needed.
• It can avoid problems inherent in an M:N relationship by creating a
composite entity or bridge entity. For example, an employee can work on
many projects OR a project can have many employees working on it,
depending on the business rules. Or, a student can have many classes
and a class can hold many students.
Degree of a Relationship Type
The degree of a relationship type is the number of participating entity types.

UNARY RELATIONSHIP BINARY RELATIONSHIP TERNARY RELATIONSHIP

also called recursive, is two entity sets is a relationship type


also called recursive, is
one in which a participate in a that involves many to
one in which a
relationship exists relationship set many relationships
relationship exists
between occurrences of between three tables.
between occurrences of
the same entity set.
the same entity set.
Attributes
In general, an attribute is a characteristic. In a database
management system (DBMS), an attribute refers to a database
component, such as a table.

It also may refer to a database field. Attributes describe the


instances in the column of a database.

SIMPLE ATTRIBUTES
Simple attributes are those drawn from the
atomic value domains; they are also called
single-valued attributes. In the SCHOOL
database, an example of this would be: Class
= {Accountancy} ; Age = {23}
Types of
Attributes
COMPOSITE ATTRIBUTES
Composite attributes are those that consist of
a hierarchy of attributes. Name may consist
of First Name, Middle Name, and Last Name.
So this would be written as → Name = {Juan
+ ‘Manzano’ + ‘Dela Cruz’}
Types of
Attributes
MULTIVALUED ATTRIBUTES
Multivalued attributes are attributes that have
a set of values for each entity. An example of
a multivalued attribute from the SCHOOL
database, the Mobile no. of student: Cellphone
Types of Number, Telephone Number, Guardian Number

Attributes
DERIVED ATTRIBUTES
Derived attributes are attributes that contain
values calculated from other attributes. An
example of this is Age, it can be derived from
the attribute Date of Birth (DOB). In this

Types of situation, DOB is called a stored attribute,


which is physically saved to the database
Attributes
KEYS
An important constraint on an
entity is the key. The key is an
attribute or a group of attributes
whose values can be used to
uniquely identify an individual
entity in an entity set
TYPES OF KEYS
There are several types of keys. These are described below.

CANDIDATE KEY COMPOSITE KEY PRIMARY KEY


A candidate key is a simple or The primary key is a candidate
A composite key is key that is selected by the
composite key that is unique and also called recursive, is
minimal. It is unique because no
composed of two or database designer to be used as
one in which a
two rows in a table may have more attributes, but it an identifying mechanism for the
relationship exists
the same value at any time. It must be minimal whole entity set. It must uniquely
between occurrences of identify tuples in a table and not
is minimal because every column
the same entity set. be null. The primary key is
is necessary in order to attain
indicated in the ER model by
uniqueness.
underlining the attribute.
TYPES OF KEYS
There are several types of keys. These are described below.

SECONDARY KEY ALTERNATE KEY FOREIGN KEY


A secondary key is an attribute A foreign key (FK) is an attribute
Alternate keys are all in a table that references the
used strictly for retrieval also called recursive, is
purposes (can be composite), for
candidate keys not primary key in another table OR it
one in which a
example: Phone and Last Name. chosen as the primary can be null. Both foreign and
relationship exists
key primary keys must be of the same
between occurrences of data type
the same entity set.
TYPES OF KEYS
There are several types of keys. These are described below.

NULLS

A null is a special symbol,


independent of data type, which
means either unknown or
inapplicable. It does not mean zero
or blank.
DESIGN RULES
BALICTAR, GUINTO, MORALES
DOMAIN INTEGRITY
The domain constrains the values of attributes in the
connection and is a relational model constraint.
In a database system, the domain integrity is defined by:
·The datatype and the length
·The NULL value acceptance
·The default Value

EXAMPLE:
KINDS OF
INTEGRITY

CONSTRAINTS:
·Entity Integrity:

: The primary key value cannot be null, according to the


entity integrity requirement.

EXAMPLE:
·Referential Integrity
Constraints:

If a foreign key in Table 1 relates to the Primary Key in


Table 2, then every value of the Foreign Key in Table 1
must be null or accessible in Table 2 according to the
Referential Integrity restrictions.
Primary Key

E
X
A
M
Primary Key
P
L
E:
·Key Constraints:

There can be numerous keys in an entity set, but only


one will be the primary key. In a relational table, a
primary key can have both a unique and null value.

EXAMPLE:
ENTERPRISE CONSTRAINTS
(BUSINESS RULES)
additional rules specified by users or
database administrators and can be
based on multiple tables
It is used to determine:
CARDINALITY is the
degree of association
between two entities

ASSOCIATION
(connectivity)
is the relationship
between two tables
Relationship Type
The lines that connect between two tables are
called relationship type. There are 2 types of
relationship: Optional and Mandatory
relationship

Optional
Relationship
Definition

In an optional relationship, the FK (Foreign


Null
Key) can be null or the parent table does
not need to have a corresponding child table Indicating "Zero or Many" symbol
occurrence.
The symbol is interpreted as zero OR many.
Example: one to many relationship
EXAMS

For example, if you look at


the Order table on the
right-hand side of Figure,
you’ll notice that a
customer doesn’t need to
place an order to be a
customer. In other words,
the many side is optional.
Mandatory
Relationship
Definition
One
In a mandatory relationship, one entity
occurrence requires a corresponding entity "One and only one" symbol
occurrence. The symbol for this relationship
shows one and only one as shown in Figure.
The one side is mandatory.

Example: one and only one relationship

Example of one and only


one relationship between
two tables.
Example: one to many relationship

"One to many" symbol

Example of one to many


relationship between two
tables.
HIERARCHICAL DATABASE
A hierarchical database is a data model
in which data is stored in the form of
records and organized into tree-like
structure, or parent-child structure, in
which one parent node can have many
child nodes connected through links.

In this model, data is stored in the form of records, which are the collection of fields.
The records are connected through links and the type of records tells which field is
contained by the record. Each field can contain only one value.
 HAT IS FIELD IN
W
DATABASE MANAGEMENT
A database field is a set of data values, of the
same data type, in a table. It is also referred
to as a column or an attribute.

Fields are arranged into records, which hold all


the information within the table related to a
specific entity. The records make up the table
rows, while the fields make up the table
columns.
- The name of each field in the record is There are different datatypes,
unique. some examples are :
1. Text
- Every field has its datatye 2. Number
*Data type indicates the type of data 3. Memo
that can be stored in a file 4. Date
Records
- a collection of related fields used as a single unit record
- it contains multiple fields/set of fields
References :
Teach Computer Science. (2021). Database Fields. Retrieved from
https://teachcomputerscience.com/database-fields/

Minitab. (2021). Types of Data Fields. Retrieved from https://support.minitab.com/en-us/engage/help-and-


how-to/tools/forms-and-analysis-captures/form-design/types-of-data-fields/

Watt, A. and N. Eng. (2014). Database Design – 2nd Edition. Victoria, B.C.: BCcampus. Retrieved from
https://opentextbc.ca/dbdesign01/.

Hall, J. A. (2011). Accounting Information System. USA: Cengage Learning.


Group 1
Atibagos, Divina
Bagsic, Armina
Balictar, Karen Mae B.
Delos Reyes, France Kevin
Guinto, Regine
Limin, Francheska Yvette
Morales, Mary Rose
Telebrico, Princress Nicole
Usman, Jasrey

You might also like