简体   繁体   English

产品如何存储在数据库中?

[英]How are products stored in database?

I have a database to store different types of products for a shop. 我有一个数据库,用于存储商店的不同类型的产品。 Do I keep record of every instance of the product? 我是否保留产品每个实例的记录? Or do I just decrease the quantity count every time a product is sold? 还是在每次销售产品时减少数量计数? I also want to store barcodes in the database. 我也想将条形码存储在数据库中。 Is the barocde printed on the product unique to every instance? 印刷在产品上的喷枪是否对每个实例都是唯一的? or is it just unique to product. 还是仅仅是产品独有的。 For instance if I have 4 cans of Heinz Tomato soup, will they have same barcode value? 例如,如果我有4罐亨氏番茄汤,它们的条形码值会相同吗? If yes then how do I identify every instance uniquely? 如果是,那我如何唯一地标识每个实例? If no then how do I guarantee that the barcode value on the Heinz Tomato Soup can will not match barcode of any other product in a given shop? 如果不是,那我如何保证亨氏番茄汤上的条形码值与给定商店中任何其他产品的条形码都不匹配?

Any help will be appreciated. 任何帮助将不胜感激。 Thank you. 谢谢。 :D :D

You don't need a record for every instance of a product. 您不需要每个产品实例的记录。

You should have an instance for a product with a stock quantity column for each record and work with the quantity field once a product gets sold or the stock gets replenished. 您应该为产品的每个记录创建一个实例,该实例的“库存数量”列应在销售产品或补充库存后使用“数量”字段进行处理。

By definition the the barcode on the products is unique (not per instance) so you should be safe with it: Heinz Tomato Soup will have a code and Heinz Chicken Soup will have another one. 根据定义,产品上的条形码是唯一的(不是按实例),因此您应该放心使用:亨氏番茄汤有一个代码,亨氏鸡肉汤有另一个代码。

This might help you more: http://www.daveegerton.com/assets/images/database-schema-prestashop.png This is the database schema used by an eCommerce (Prestashop). 这可能对您有更多帮助: http : //www.daveegerton.com/assets/images/database-schema-prestashop.png这是电子商务(Prestashop)使用的数据库架构。 Your questions answer is in the right bottom square the one in light brown :) 您的问题的答案是在右下角的方框中浅棕色:)

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

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