书店的ER图

时间:2015-02-22 23:02:33

标签: database-design entity-relationship

我有一个book store application,我想设计它的数据库。然后首先我需要它的E-R图。

(This is not homework)

它有如此简单的场景:

  • 每位用户可以拥有0,1或更多的图书订单。

  • 每种类型的图书都有多个实例。

这是最好的设计吗?

enter image description here

1 个答案:

答案 0 :(得分:0)

书籍和订单之间应该有一个链接,而不是书籍和订单。 'orders'表应该是中央表。一个简单的结构将是

CUSTOMERS
id
name
adddress, etc

ORDERS
id
customer  (foreign key to customers table)
curdate
status  (open, closed)
% discount

ORDERITEMS
id
order    (foreign key to orders table)
book     (foreign key to books table)
quantity
price    
% discount
status (open, closed, ordered from distributor?)

BOOKS
id
title
author
costprice
salesprice
isbn