如何改善此数据库模型? [英] How can I improve this database model?

查看:240
本文介绍了如何改善此数据库模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对与客户的DVD销售和DVD租赁关系进行建模。尽管我认为我的交易表不正确。如果有人能让我知道我是否朝着正确的方向前进,那将是很棒的设计。

I'm trying to model the relationship of dvd sales and dvd rentals to a customer. Although I dont think my transction table is correct. If anyone can let me know if I'm goin in the right direction with the design that would be great.

推荐答案

这是一种设计方法。

我不是数据库专家。我为带有少量表的小型应用程序设计了数据库。我尝试 (强调尝试,有时我会失败)尽可能地通用一些,因此在范围变更时,我不会局限于角落。

I am not a database expert. I have designed databases for small sized applications with few tables. I try (emphasis on try, sometimes I fail to) to be more generic as possible so I am not confined to a corner when there is a scope change.


  1. 在您的图表中,我注意到一些事情,例如您仅出售DVD的假设。如果商店所有者开始销售蓝光光盘或便携式游戏机,会发生什么情况。我的建议是保持设计通用。所以我将DVD桌子改成了Item,以便桌子可以容纳任何东西。

  1. In your diagram, I noticed few things like your assumption of selling only DVDs. What happens if the shop owner starts to sell Blu-ray discs or portable game consoles. My suggestion would be to keep the design generic. So I rephrased the DVD table to Item so that the table could hold anything.

我还添加了商品类型表,以便您可以定义商品的类型。

I also added Item type table so that you can define what type of item it is.

您的交易应视为一个订单。客户可以下一个订单,其中可以包含他们要购买的一组商品以及要出租的少量商品。您不会要求他们两次刷卡,对吗?而是在订单抬头中为客户创建订单,并将其订单项放置在订单明细表中。订单明细表还将指定数量,例如客户想要购买/租用多少物品。他们租房时,返回日期字段开始时为null。当他们退货时,您可以通过搜索商品ID和客户ID组合返回并填写日期。

You transactions should be considered as a single order. A customer can place a single order that can contain a set of items they would like to purchase and also few items that they would like to rent. You wouldn't ask them to swipe the card twice, would you? Instead, create an order for the customer in the Order Header and place their line items in the Order detail table. The order detail table would also specify quantity like how many items the customer would like to purchase/rent. When they rent, the return date field would be null to begin with. When they return the item, you can go back and fill in the date by searching for the item id and customer id combination.

您可以通过 n 种方式进行设计,但是由于信息有限,这是我能想到的。

You can design this in n number of ways but with limited info, this is what I could come up with.

我并不是说这是最好的设计。我希望这给您一些想法,可以从这里开始使用它,并根据需要进行微调。.

I am not stating that this is the best design. I hope this gives you some idea to take it from here and fine tune it according to your needs..

这篇关于如何改善此数据库模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆