Lecture 3IS099
Lecture 3IS099
IS 099
Lecture 3: Basic Entity Relationship Modeling
Lecture Outline
• Data Modeling
• Entity-relationship model
• Features of ER-model
• Intro to ERDs
• Entity and Attribute
• Entity set
• Strong and weak entity
• Attribute types
• Key attribute
Data modeling
A model is a simplified version of real-life, complex objects.
Databases are complex, and data modeling is a tool to represent the various components and their relationships.
Data model is a collection of conceptual tools for describing data, data relationships, data semantics, and
consistency constraints.
Define how data is connected to each other and how they are processed and stored inside the system.
Describes/underlies the logical structure of a database
Main types of data model includes:
- Entity-relationship (E-R) model
- Relational model
Other models:
- Object-oriented model
- Semi-structured data models
- Older models: network model and hierarchical model
The entity - relationship (E-R) model is a very popular modeling tool among many such tools available today.
Entity-relationship model
• Entity-relationship (ER) modeling is a data modeling technique used in software engineering to produce a
conceptual data model of a information system.
• The (ER) data model is based on a perception of a real world
that consists of a collection of basic objects (entities), and relationships
among these objects. And their graphical representation in a database.
• The main components of ER model are: entity sets, relationship sets
and attributes.
• It describes the database structure with the help of diagrams known as Entity-Relationship Diagrams or ER
diagrams or ERDs.
About- ER model
The main features:
• Entity relationship model is a high level conceptual model
• This model is used to define the data elements and relationship for a specified system
• It is widely used to develop an initial design of a database
• It provides a set of useful concepts that make it convenient to develop a very simple and easy-to-design view of
data for the database.
• In ER modeling, the database structure is portrayed as a diagram called an entity-relationship diagram.
• It describes data as a collection of entities, relationships and attributes.
Introduction to ER diagrams
• Is a visual representation of different data using conventions that describe how these data are related to each other.
- An ER diagram shows the relationship among entity sets.
- It is a design or blueprint of a database that can later be
implemented as a database.
Entity
• An entity is something that exists by itself, and can be easily identifiable.
• Entity: Real-world object distinguishable from other objects. An entity is described using a set of attributes.
- For example, in a school database, students, teachers, classes, and courses offered can be considered as entities.
- Others are person, book, customer, bank account etc.
- All these entities have some attributes or properties that give them their identity.
• An entity is represented in the E-R diagram by means of
rectangles. Rectangles are named with the entity set they represent.
Note: Use singular names rather than plurals, because entity apply for each individual entity
• Example of entities
- Person: EMPLOYEE, STUDENT PATIENT
- Place: STORE, WAREHOUSE
- Object: MACHINE, PRODUCT, CAR
- Event: SALE, REGISTRATION, RENEWAL
- Concept: ACCOUNT, COURSE
Entity set
• The collection of entities of the same kind.
- An entity set may contain entities sharing same attributes, but have their own values for each attribute.
- For example, a Student set may contain all the students of a school; likewise a Teachers set may contain all the
teachers of a school from all faculties.
- Another example: a company hiring hundreds of employees may want to store similar information.
• Entity sets need not be disjoint.
• Each entity set has a key ( a set of attributes uniquely identifying an entity).
Weak entity
• A weak entity is an entity that depends on the existence of another entity. For example, a room can only exist in a
building, or a bank account can’t be identified without knowing the bank.
• In more technical terms it can defined as an entity that
cannot be identified by its own attributes.
• A weak entity can be identified uniquely only by considering
the primary key of the parent/owner entity. In this case, the parent
entity is a strong entity.
• Therefore, it must use a foreign key in conjunction with its
attributes to create a primary key. The foreign key is typically a primary key of an entity it is related to.
Key attribute
• Key is an attribute or collection of attributes that uniquely identifies an entity among entity set.
• Keys are very important in relational database. They are used to establish and identify relation between tables.
Thus, key attribute represents a primary key.
Primary key uniquely identifies a record in the Foreign key is a field in the table, that is a primary
table key in another table
Primary key can not accept null values Foreign key can accept multiple null values
We can have only one primary key in a table We can have more than one foreign key in a table
Non-key attributes
• Non-key attributes are attributes other than candidate key attributes in a table.
Non-prime attributes
• Non-prime attributes are attributes other than primary attributes
Attributes
• Attributes are properties of entities.
- For example, a student entity may have name, class, and age as attributes. Others include account-number and
balance for account entity in a bank, customer-id, customer-name, customer-address for a customer entity, book
code, book title to describe a book entity.