本文介绍了数据库:设计客户订单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在创建一个Android应用程序,应该使用SQLite数据库。在我的情况下,我需要填写产品类型,帐单和所有购买的产品的列表



比尔: p>

  id 
customer
data - >链接到所有购买产品的列表
price

产品类型:

  id 
name
price

我的问题是:一个客户可以有更多的产品连接到一个帐单。如何设计呢?使用a为每个帐单使用一行:

  id 
bill_id
product

或者将更多的产品插入一行,然后在我的应用程序中解析它?我想,有一个更好的解决方案,这些矿。

解决方案

您在问题中说:一个客户可能有更多产品连接到一个帐单。 / p>

另一种说法是,一个客户可以有0个或更多的帐单,一个帐单可以有1个或更多的产品。



重新表述您的声明后,变得更加明显。

 客户
--------
客户ID
客户名称
。 ..

Bill
----
帐单ID
客户ID
帐单时间戳

帐单 - 产品
------------
帐单ID
产品ID

产品
-------
产品ID
产品名称
产品价格
...


I am currently creating an Android application which should use SQLite database. In my case, I need to strore "product type", "bill" and "list of all purchased products"

Bill:

id
customer
data -> link to list of all purchased products
price

Product types:

id
name
price

My question is: One customer could have more products connected to one bill. How to design it? Is using a Use a one row for every bills:

id
bill_id
product

or rather insert more products into one row and then parse it in my application? I suppose, there is a better solution that these mine. Thank you for help.

解决方案

You said in your question, "One customer could have more products connected to one bill."

Another way of saying this is, one customer can have 0 or more bills, and one bill can have 1 or more products.

After rephrasing your statement, the database normalization becomes more obvious.

Customer
--------
Customer ID
Customer Name
...

Bill
----
Bill ID
Customer ID
Bill Time Stamp

Bill-Product
------------
Bill ID
Product ID

Product
-------
Product ID
Product Name
Product Price
...

这篇关于数据库:设计客户订单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 23:08