简体   繁体   English

销售/租赁电子商务的数据库设计

[英]Database design for a sell/rent eCommerce

I am working on my school project to create an eCommerce website that sell and rent product. 我正在研究我的学校项目,以创建一个销售和租赁产品的电子商务网站。

My main problem is that I can't find the best design for the "Renting" part. 我的主要问题是我找不到“租赁”部分的最佳设计。 For now I am thinking about two designs: 现在我想到两个设计:

The first database design suggestion: 第一个数据库设计建议: 第一个数据库设计建议


The second database design suggestion: 第二个数据库设计建议: 第二个数据库设计建议

As you can see there are the same tables in both designs but with different relations, but I can't tell which one is better. 正如你所看到的,两种设计中都有相同的表,但关系不同,但我不知道哪一种更好。

I will be happy if you can tell me which design is better or if there is a better way to design my database altogether. 如果您能告诉我哪种设计更好或者是否有更好的方法来设计我的数据库,我将很高兴。

Think of your problem from the real-life perspective: 从现实生活的角度考虑您的问题:

  1. You will be offering “something”, being products in your schema; 您将提供“某些东西”,作为您架构中的products ;
  2. You will be working with “somebody” or customers in your schema. 您将与架构中的“某人”或customers

These 2 tables are most important, as without them the whole thing has no meaning. 这两个表是最重要的,因为没有它们,整个事情都没有意义。

Next, in real life, you have to have papers for each deal you'll make in order to: 接下来,在现实生活中,您必须为每笔交易制作论文,以便:

  1. Report to authorities and pay taxes (don't you like to pay taxes?); 向当局报告并纳税(你不想纳税吗?);
  2. Keep track of products that are “on hands” of your customers. 跟踪客户“手头”的产品。

These are orders of 2 types: purchase and rent. 这些是2种类型的orders :购买和租赁。

Note, though, that it is unlikelly to rent a set of products with different return dates in one order. 但请注意,在一个订单中租用一组具有不同退货日期的产品是不可取的。 Typically, one will rent a set of related items for some special case, like wedding celebration or bathroom repair. 通常情况下,人们会为一些特殊情况租用一套相关物品,如婚礼庆典或浴室维修。 In case you need some products for 2 days while others for 2 weeks, it is better to create 2 orders, as different delivery conditions or discounts may apply. 如果您需要一些产品2天而其他产品需要2周,最好创建2个订单,因为可能适用不同的交付条件或折扣。

Therefore I think that initial variant #1 matches your goal better with the following updates: 因此,我认为最初的变体#1与以下更新更好地匹配您的目标:

  1. order_type column should be added to the orders table; order_type列应该添加到orders表中;
  2. rent_details should relate to orders table; rent_details应与orders表相关;
  3. rent_details should have only order_id in place of rent_detail_id + order_items_id ; rent_details应该只有order_id来代替rent_detail_id + order_items_id ;
  4. it very necessary to have a separate price column in the order_items table along with discount ; order_items表中有一个单独的price列以及discount是非常必要的;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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