0

我想创建一个Postage_costs表来保存邮费,每个postage_cost都有一个名称,例如大项目,它有不同的成本(标准价格和快递邮费),具体取决于位置,所以Large_Item可能看起来像;

Name: Large Item
Cost: UK:
         standard: 5
         express: 10
      Europe:
         standard:10
         express
      R.o.w:
         standard: 20
         express: 30

我最初将 Name 作为字符串,将 cost 作为文本字段,其中包含哈希的序列化内容,但是创建新国家及其汇率变得有点困难。我宁愿把它全部放在一张桌子上,那么有更好的方法吗?我正在使用 rails 和 PostgreSQL

4

2 回答 2

1

Serializing has some disadvantages. For example, you cannot create database indexes on the serialized contents in order to optimize you queries. Also, application validations are going to be a mess.

My suggestion is to just have 2 extra columns on your table. So have something like:

postages
  name
  country
  standard_price
  express_price 
于 2013-06-07T17:34:43.253 回答
0

每个国家都有一个条目。

name: Large Item
country: UK
standard_price: 5
express_price: 10

name: Large Item
country: Europe
standard_price: 10
express_price:

name: Large Item
country: Europe
standard_price: 20
express_price: 30
于 2013-06-07T17:31:46.573 回答