2014-10-02 28 views
0

我使用以下表单将表单中的每个字段以电子邮件形式发送给某人。不过,我希望将这些字段存储到数据库中,并将每个订单链接到一个销售代表(我已经设置好)。我应该为order_details创建另一个表来存储这个表。 Pease help enter image description here将数组信息传递到数据库中

+0

挺难回答你的问题,因为它是不是100%清楚你想要达到的目标。你有什么样的物品,它们有什么关系? – Juru 2014-10-02 08:43:28

回答

1

这一切都取决于你想如何构建你的数据。没有银弹解决方案。但我会做三张桌子。 SALES_REPRESENTATIVE,订单和ORDER_DETAILS。销售代表有订单,订单有订单详情。

因此根据您的意见。

如果你有一个产品定义表,你可能会有一个名为可口可乐的产品,另一个产品是芬达和他们的单价。

订单明细表可包含产品表的链接并指定数量。

订单表中将包含该订单的订单详细信息的链接,例如订单的订购日期。

销售代表可能会链接到与他有关的所有订单。

具体的例子:

PRODUCTS table 
Id Name   Price in $ 
1 Coca-cola 1.00 
2 Fanta  1.10 

ORDER_DETAILS 
Id Order_Id Product_Id Quantity 
1 1  1   10  // meaning this order detail is 10 Coca-cola's 
2 1  2   20  // meaning this order detail is 20 Fanta's (because the tast is better :)) 
3 2  2   10  // meaning this order detail is 10 Fanta's 
//Here Order_id is a foreign key to the Column Id of Table ORDERS 
//And Product_id is a foreign key to the Column Id of the Table PRODUCTS 

ORDERS 
Id Sales_Representative_Id Order_Date 
1 2      10/17/2014 // Order one made by Luke on 17th october 2014 
2 1      10/19/2014 // Order two made by Anna on 19th october 2014 
//Here Sales_Representative_id is a foreign key to the Column Id of Table SALES_REPRESENTATIVES 

SALES_REPRESENTATIVES 
Id Name 
1 Anna 
2 Luke 
+0

非常感谢你。我有一张“salesReps”,“orders”和“orderDetails”的表格,我知道我必须链接ID来提取相关信息.....正确吗?所以在orderDetails表中我存储了表单中的所有行或者只是prouct ID? – Dom 2014-10-02 08:46:30

+0

在orderDetails中,您可以存储哪些产品在订单中,以及每类产品的数量。也许你也需要产品表和产品定义。我会在我的回答中添加一些关于这方面的信息。 – Juru 2014-10-02 08:48:14

+0

这对我来说很清楚。谢谢你的所有帮助,我会让你知道Juru我怎么样! – Dom 2014-10-02 09:11:52

相关问题