0% found this document useful (0 votes)
19 views45 pages

Chapter 4 - Conceptual Database Design

Data Management Systems San Diego State University - Chapter 4

Uploaded by

Ibrahima Diallo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views45 pages

Chapter 4 - Conceptual Database Design

Data Management Systems San Diego State University - Chapter 4

Uploaded by

Ibrahima Diallo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

Chapter 4: Conceptual

Database Design
DATABASE MANAGEMENT AND DESIGN – ERD
Why Conceptual Design?
Requirements definition is one of the most difficult tasks of database design.
When databases are built without rigorous data modeling, the resulting
database is frequently inadequate to answer important queries.
The rules for a correct detailed data model enforce a rigorous definition of
user requirements.
A good conceptual design captures the “real” world with precision and
accuracy.
A diagram of data design follows the “Picture is worth a thousand words”
principle. Conceptual models are
◦ Graphical – easy to visualize
◦ Intuitive – easy to understand
◦ Technical – precise definition based on specific rules
Mapping Conceptual and Logical Models
Modeling Element Logical Model Conceptual Model
“Thing” of interest Relation (table) Entity
Characteristic Attribute (column) Attribute
Instance Tuple (row) Instance
Conceptual Data Models
Entity-Relationship Diagramming (ERD)
§ Is a diagram that represents the entities and their relationships in a database
§ Helps to design a database

Unified Modeling Language (UML)


§ Industry standard entity-oriented modeling language
§ gives a standard way to write a system model, covering conceptual ideas
Fundamentals of Conceptual Data Modeling
Principal elements are
§ Entities – think of “things” as described by nouns
§ Relationships – think of connections as described by verbs
Categories of entities that may be included in Data Modeling
§ Tangible things -- vehicle, person, document
§ Roles -- customer, doctor, employee
§ Organization units -- department, workgroup
§ Devices -- controller, computer, sensor
§ Sites or locations -- retail store, warehouse, branch
§ Incidents or events -- flight, sale, order, payment
§ Abstract entities -- bank account, product design, skill
Definitions in ERD data modeling
Entity Set – The set of all instances with the same characteristics (also just called
an Entity or a Set)
Entity Instance – A single entity within the Entity Set (also called an Instance)
Attribute – A property (or attribute) of the entities in an entity set
Relationships – connections or links between the instances in one entity set
with the instances in another entity set
Entity-Relationship Diagram (ERD) – A diagram showing the entity sets and
relationships between entity sets.
Notation for Entity Sets
Rectangle with Capitalized entity name (singular noun)
Rectangle divided in two major compartments for entity name and list of
attributes
Terms
Lexical Set – A Set of instances that can be written and read. Example: Social Security Number.
Abstract Set – A Set with instances that cannot be written. Example: Person, Vehicle
Identifier – An internal number to uniquely identify an instance in an Abstract Entity Set

Surrogate Key – An attribute or set of attributes that


can serve as an identifier, i.e. which can uniquely
identify instances (sometimes just referred to as a key).
Specialization and Generalization
Specialization Entity is a subset of Generalization Entity. Instances in
a Specialization also are instances in the Generalization.
Notation is a triangle with a
connecting line from Generalization
to the Specialization.
Multiple Specializations
Generalization (superset) vs Specialization (subset)
Complete vs incomplete
Disjoint vs overlapping
Relationships
Relationship is sometimes called an Association (in OO terms)
Links two or more sets. Notation is a connecting line with Diamond.
At the instance level, it connects specific instances of one Entity Set
to specific instances of the other Entity Set.
Unary relationship links instances of an Entity Set to other instances
of same Entity Set. Example: Employee manages Employee.
Binary relationship is between two Entities
N-ary relationship is between multiple Entities.
Relationships example
Name is “Student took Course”

AND it means
Adam took Physics 211
Joan took Math 351
Joan took Sociology 101
Relationship Example
More realistic model which records a students grade.
Add Enrollment and Grade Entities.
Associative entity
Relationship Example 2
Supervisor Entity contains {Paula, Craig}
Worker Entity contains {Kent, Bruce,
Heidi, Ralph, JoEllen}
Entities can have multiple Relationships
Cardinality
The maximum number of instances in one set that are related to a
single instance in the other set in the relationship
Cardinality Types:
◦ 1:1
◦ 1:M
◦ M:N
Cardinality
The number of instances in one Entity that are related to a single instance in the other
Entity in the relationship
§ Notation is Number on the opposite end of the line
§ Part (a) reads: Each Person has only one Social Security Number
§ Part (b) reads: Each Person has only one Social Security Number and each Social Security
Number belongs to only one Person.
Minimum and Maximum Cardinality
Minimum Cardinality is the minimum number of connections for an
instance to instances in the related Set. Typical values are:
0 – means an instance is not required to have any connections to the related Set
1 – means an instance must have at least one connection to an instance in the
related Set
Maximum Cardinality is the maximum number of connections for an
instance to instance in the related Entity Set, i.e. the maximum number
of instance that the first instance can be related to. Typical values are:
1 – means an instance can only be connected to one instance in the related Set
* -- means an instance can be connected to many instances in the related Set
Example Cardinalities
A person instance can have zero to one connections with a Social Security Number instance
A Social Security Number instance can have zero to one connections with a Person instance.
Another Example of Cardinality
Supervisor has cardinality of one to many Workers. (Minimum of one, Maximum of many)
Worker has cardinality of one and only one Supervisor. (Minimum and Maximum of one)
Generalization and Specialization
Cardinalities
Generalization/Specialization
always has these cardinalities.
A Specialization instance must
ALWAYS also exist in the
Generalization (Min and Max of 1).
A Generalization instance may or
may not exist in any particular
Specialization (Min of 0, Max of 1).
Normally these are cardinalities are
not shown on a diagram.
Overview of
Cardinalities
Attributes
Properties of each instance in an Entity Set
Special attributes
§Primary Key – The surrogate key chosen as the primary identifier
§Foreign Key – The key of a different Entity. To support Relationships
Inheritance
§Specialization and Generalization
o Specialization inherits all attributes of generalization
o Specialization inherits all relationships of generalization
Nouns as entities or Attributes
Nouns can be Lexical Entities with zero to one Lexical Sets should be modeled as attributes if
or one to one cardinality they are properties of an Entity Set
Key Attribute
As defined previously, a KEY is an attribute that is a
unique identifier for each instance within an Entity
Set. Normally in a database, every record will have a
KEY attribute
§ External Key – A key attribute that has external use and
value, such as Social Security Number for Person.
§ Internal Key – A key attribute that is created for internal
use, usually a unique binary number.

Note: BankCustomer has SSN attribute,


which is a unique identifier, but it is better
to create an Internal Key of CustomerNumber.
Inheritance
Inheritance is a characteristic of
Generalization/Specialization:
§The Specialization Set inherits the
attributes of the Generalization.
§A MarriedPerson (such as John Doe)
has Social Security Number, Name,
Address as well as Spouse Name.
Example- 1
1. Primary Key
2. Composite attribute
3. Multivalued attribute
4. Derived attribute
Example 2

Partial key

Weak Entity
4-4 More Examples:
Red Cat Shoes – Initial Relational Model
From Chapter 3. The Relational Model for the Initial Red Cat Shoes model is:
Sale (SaleID, SaleDate, CustomerID, ProductID, ItemSize, Quantity, SalePrice)
◦ Foreign Key: CustomerID references Customer
◦ Foreign Key: ProductID references Product

Customer (CustomerID, FirstName, LastName, StreetAddress, City, State, PostalCode, Country, Phone)

Product (ProductID, ProductName, ManufacturerID, Category, Color, Price, Description)


§ Foreign Key: ManufacturerID references Manufacturer

Manufacturer (ManufacturerID, ManufacturerName, Address, City, State, PostalCode, Phone)


Conceptual
Data Model

via Reverse
Engineering from
Relationship
Model
Enhancing Red Cat Shoes
Three primary components are missing from the previous, simple Red Cat Shoes
ØRed Cat has employees. We need to address the database requirements for
recording the employee and management structure of Red Cat.
ØSales typically include more than one product. Up till now, we have assumed
only a single product on each sale.
ØProducts must be purchased from manufacturers. We have not included
anything in our data model about product purchases.
Enhancing Red Cat Shoes Sales
A Product is a type of shoe. However, Products come in various Sizes. And sales
come out of Inventory.
Note Products come in multiple Sizes and a Size can apply to multiple Products.
An Inventory Item is an Entity Set between Product and Size.
Enhancing Red Cat Shoes Sales (cont)
A Sale Item is a Sale of Inventory
Items.
Note: A Sale can now have multiple
Sale Items on it. And each Sale Item is
a single Inventory Item. An Inventory
Item (Product-Size combination) can
be on multiple Sales Items.
Adding
Purchases to
Red Cat Shoes
New entity sets are
Purchase and Purchase
Items.
Red Cat Shoes

Final Conceptual
Model
Relationship Sets – University Case
Initial model for Student enrolled in a Course.
Nouns as Attributes
Nouns (as lexical entity sets) become attributes if they are Properties with a
one-to-one cardinality to the dominant entity set. Grade is a property of
Enrollment.
Adding Professors – University Case
Additional entity sets and relationships.
Teaching Assignment is Professor is assigned to Course.
Enhancing the Course Entity Set
Previous diagrams did NOT model
reality well enough. Real life is more
complex.
A Course may have multiple Sections,
and a Student is enrolled in Course
Sections,

AND Professors teach Course Sections.

Note: A Section (CourseSection) has


multiple Students and Students enroll
in multiple CourseSections.
Enhancing the Course Entity Set (Cont)
Professors are assigned to
individual Course Sections via
Teaching Assignments.
Note that a Professor may
have multiple Teaching
Assignments to teach
Sections, but that a Section
my also have multiple
Teaching Assignments of
Professors assigned.
Enhancing University Case with Time
Courses and Sections are taught during multiple seasons (fall, winter, summer)
during multiple years (2018, 2019, 2020). One way to capture time information
is to define a Term as having a Season and a Year.
Comprehensive
University Data
Model
Combining previous
models yields a more
complete data model.
Note the cardinalities to
understand the real-life
constraints on entity
sets and relationships.
Verifying the Data Model by answering
queries.

What terms did John Gray take


Sociology101?
What grades did he get each
time?
Who were the professors that
taught his sections?
Did he use the same textbook
each time?

You might also like