Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
插入记录时哪个数据库设计更好?
**Option 1.** uid|itemid| qty | price | amount 1 |13| 2 | 100 |200 **Option 2.** uid| itemid| qty | price | amount 1 |13| 1 | 100 | 100 2 |13| 1 | 100 | 100
在选项 2 中,然后通过 mysql 查询检索行并使用 id 计算...
您似乎想保留订购的每件商品的原价。我要做的是使用选项 1,然后在表中创建另一列,其中包含一个字符串,该字符串标识订单中的每个项目。
例如,如果我在卖水果,香蕉可以iZ作为唯一键。苹果可以6U作为唯一键。当用户下订单时,这些唯一键将插入到您的新列中。因此,当您看到此列的数据时,iZ6U您就会知道用户订购了一个苹果和一个香蕉。
iZ
6U
iZ6U