简体   繁体   中英

Class Diagram for Book Shop

I am starting a project creating a management system for a book shop. I have created a simple entity class diagram as you can see below. I just wanted some guidance on whether the relationships are correct for the entities? 在此处输入图片说明

The relationships meaning:

  • 1 order can be placed for many items of stock and a stock item can exist without an order.

  • 1 book is 1 item of stock and a book cannot exist without its counterpart stock item

  • each book can have many publishers and a book cannot exist without a publisher

  • Finally ebook and paper book are sub classes of the super class book as they are both "books"

I agree with the aggregation relationship between order and stock; but note that n can equal zero. Can there be an order of no stock? Also consider the direction of the relationship. Does stock have an order, or does an order have stock?

The model shows a composition relationship between stock and book; however, your description states that a book is stock. An is a relationship should be modeled by generalization, rather than composition.

The model shows that many books have one publisher. Per your description, it would be more accurate to say that many books have many publishers. Also the direction of the composition relationship in the model indicates that a publisher cannot exist without a book; whereas your description states the opposite.

Finally, the model shows a directed associated between book and its subclasses; whereas your description (correctly) implies generalization, which should be modeled as a closed arrowhead.

reference: UML basics: The class diagram

  1. You lack the info on the navigabilities at all.
    • Stock<->Order (can be one-sided)
    • Stock->book
    • Book-> publisher
  2. The full rhombuses should be moved to the other ends of connections. It is the book that can't be without publisher, not vice versa.
  3. Child books should be connected to Book by arrow with empty triangles on the ends. It is that arrow who means being a child of.
  4. A book can be represented by many exemplars in the stock. Correct the multiplicity.
  5. Make the book abstract class.

One question I don't know: Have ebooks a number of exemplars in stock? Or they have different logic?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM