SDD Topic has been refreshed!
There was a 1:M relationship between 5 related tables.
A strong entity is one whose existence does not depend on the existence of any other entity in the same database. The primary key of a strong entity uniquely identifies each occurrence within the entity.
A weak entity is one that depends on one or more strong entities for its existence. For this reason, strong entities are sometimes referred to as owner entities. A weak entity cannot be used independently because its existence depends on one or more owner entities. The primary key of a weak entity is formed, in part, using the primary key of its owner entity(ies).
If we look at the Supplier, Item, Order and Customer entities a record can be uniquely identified using their own attributes. So these would be classed as strong entities. The OrderItem entities’ Primary Key depends on attributes from other entities so it would be classed as weak entity.
A weak entity always depends on the strong entity for its existence whereas, a strong entity is independent of any other entity’s existence. So when classifying an entity as strong or weak the relationship between the entities is key.
Weak entities will be shown by a double line line to represent the relationship between the weak entity and its owner entity.
The weak entity itself is indicated by using optionality (more on this next).
We can further describe the relationship between entities by describing their participation. That is the nature of the relationship between the entities:
Mandatory Participation
Describes a relationship where at least one occurrence of an entity must exist before any occurrences can be added to its associated entity. The mandatory side of any relationship is indicated by using a vertical line.
Optional Participation
Describes a relationship between two entities where it is possible to add occurrences of one entity without the need to have existing occurrences in the associated entity. The optional side of a relationship is indicated by using a bold circle.
There are many different ways to represent the relationships between entities and one such set are shown below
Relationship participation symbols
The participation can be identified using an entity occurrence diagram.
If we look at the supplier and item entities we will see that every item has a supplier but not every supplier has an item.
Supplier:Item has a 1:M relationship
For the relationship between Supplier and Item there has to be a supplier. So supplier is mandatory.
It is possible that a supplier will not supply any items so there may not be a corresponding item so item is optional.
This is shown in an ER diagram as below:
If we look at the item and orderitem entities we will see that every orderitem is an item but not every item is an orderitem.
Item:OrderItem has a 1:M relationship
For each occurence of OrderItem there has to be a corresponding record in Item so Item is mandatory
For every Item there may not be a corresponding occurence in OrderItem so Orderitem is optional
This is shown in an ER diagram as below:
If we look at the order and orderitem entities we will see that every orderitem is an order but not every order has every item.
Order and OrderItem has a 1:M relationship.
OrderItem has optional participation as an order has the option of having an OrderItem
Order has mandatory participation as every OrderItem must be contained in an order and there has to be a corresponding entry in the OrderItem entity
This is shown in an ER diagram as below:
If we look at the order and customer entities we will see that every order is made by a customer but not every customer has placed an order.
Customer and Order has a 1:M relationship
Every order must have a corresponding customer so customer is mandatory
Not every customer may place an order, so there may not be a corresponding order for every customer so order is optional.
This is shown in an ER diagram as below:
Original without Strong/Weak or Participation
New ER diagram showing Strong/Weak entities and Participation
A travel agency uses a relational database to store details on a booking system.
It stores details of Scottish holiday resorts, hotels in each resort, customers and their bookings. These details are arranged in four separate entities as shown below.
From the list of attributes, we can see that Resort, Hotel and Customer are all strong entities while Booking is a weak entity.
An entity-occurrence diagram indicating the relationships between the entities is shown below. Using an entity-occurrence diagram helps to clarify the nature of each relationship.
From the entity occurrence diagram we can see that not every resort has a hotel but every hotel is at a resort.
The entity-occurrence diagram for the system makes it clear that:
Resort: Hotel is a 1: M relationship:
Resort has mandatory participation in this relationship:
every hotel is located in exactly one resort
Hotel has optional participation in this relationship:
a resort may or may not have a hotel
From the entity occurrence diagram we can see that not every hotel as a booking but every booking must have an associated hotel.
The entity-occurrence diagram for the system makes it clear that:
Hotel: Booking is a 1: M relationship:
Hotel has mandatory participation in this relationship:
each booking must be associated with exactly one hotel
Booking has optional participation in this relationship:
a hotel may exist without bookings
From the entity occurrence diagram we can see that not every customer has made a booking but every booking must be by a a customer
The entity-occurrence diagram for the system makes it clear that:
Customer to Booking is a 1: M relationship:
Booking has optional participation in this relationship:
it is possible that some customers never make a booking (for example, details of customers on the mailing list will be stored in the database, even though they have never made any bookings)
Customer has mandatory participation:
every booking must be associated with a customer