When should we use weak entities when modelling a database?

This is basically a question about what are weak entities? When should we use them? How should they be modeled?

What is the main difference between normal entities and weak entities? Does weak entities correspond to value objects when doing Domain Driven Design?

To help keep the question on topic here is an example taken from Wikipedia that people can use to answer these question:

In this example OrderItem was modeled as a weak entity, but I can’t understand why it can’t be modeled as a normal entity.
Another question is what if I want to track the order history (i.e. the changes in it status) would that be a normal or weak entity?

Formally a “weak” entity has the following characteristics.

  1. It is existence-dependent on another entity.

    i.e., it cannot exist without the entity with which it has a relationship.

  2. It inherits at least part of it’s primary key from the entity to which
    it is related.

    i.e. -> A weak entity’s primary key must be a composite key that includes the primary key of the entity on which it is existence-dependent.

I would say that in practice you wouldn’t overtly decide to make something a “weak” entity per se; you would instead structure the data to be representative of whatever you are trying to model.

If, after you have done this, you look at a particular entity and it has the characteristics of a “weak” entity, you can document or diagram it accordingly, if for some reason you feel the need to explicitly call this out or for the sake of formality.


If you define your OrderItem to have a uniquely identifying sequential id, and the OrderId is not part of the key, then you are treating OrderItems as first order citizens and don’t really have a weak entity.

You could FK other tables to OrderItems individually if you wanted to; it is unnecessary to already have an OrderId to get at OrderItems. On the other hand if you keyed OrderItem with OrderId and a sequenceId (or similar) relevant to the Order, you would have a weak entity and individual line items would only be referenceable using the OrderId and sequenceId. Model usage as intended.

3

An OrderItem can not exist without an order or an product. Hence it’s weak since it’s dependencies control it.

If you for instance remove the order you have no way of knowing where the item should be shipped. Or if you remove the product you don’t know what to ship.

According to my understanding in the above diagram they have included the two entities/tables instead of one i.e orders and order item so that accessing the information becomes easy when two entities are designed. And order item is dependent on orders entity so it is considered as an weak entity. because the characteristic of weak entity is it depends on another entity. Suppose if you do not include order item entity how will you be able to know order item’s price,discount. and as jgauffin said If you for instance remove the order you have no way of knowing where the item should be shipped. Or if you remove the product you don’t know what to ship.

The ER diagram is to be designed according to the business requirement.

See ,a order has many order items(multivalued attribute).
Thus according to rule we create separate table.

Now,let’s say 2 customers has same order.e.g both buy iPhone at same price,discount, same date,etc.
So ideally there should be two exact tuples for order of iPhone in orderitem relation. But according to constraint of a relationn,all the tuples should be unique.
So lets relate two orders to same item_line_number.no problem uptil now.
Now consider one of the customer cancels. Is iPhone order.also the item_line_number tuple will be deleted.
Now other customer’s who bought iPhone also gets deleted because of M:1 correspondence.
So finally the database is inconsistent.
That’s why we use a descriptor key which will be orderid.thus deleting one iPhone ordered doesn’t cause database corruption.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật