Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails关于规划数据结构的建议_Ruby On Rails_Database Design - Fatal编程技术网

Ruby on rails Rails关于规划数据结构的建议

Ruby on rails Rails关于规划数据结构的建议,ruby-on-rails,database-design,Ruby On Rails,Database Design,我正在建立一个库存跟踪工具,帮助人们跟踪独特的物品(一次性-比如一件老式T恤)或一组物品(我有数量的T恤设计)。数据结构将非常相似,因此: **Item** Title Status (sold, for sale) <- right now this is a simple array Location <- this is a relationship to a diff model etc... **Item Group** Title Quantity Status ([

我正在建立一个库存跟踪工具,帮助人们跟踪独特的物品(一次性-比如一件老式T恤)或一组物品(我有数量的T恤设计)。数据结构将非常相似,因此:

**Item**
Title
Status (sold, for sale) <- right now this is a simple array
Location <- this is a relationship to a diff model
etc...


**Item Group**
Title
Quantity
Status ([quantity] sold, [quantity] for sale) <- this should be an hstore??
Locations ([quantity] location1, [quantity] location2) <- not sure about this yet!
etc...
**项目**
标题

状态(已售出,待售)减少您的头痛,不要区分独特物品和非独特物品(即,所有物品都有数量)

然后您需要一个“purchace”模型,然后一个“item\u purchace”模型作为联接表


按照这里的布局:

我不明白你对一组项目的想法?为什么不只是一个名为items的表并存储数量呢?我想这只是UX的一个区别…不是-你只是没有很好地设计你的数据库-你需要考虑规范化-特别是关于
项目组中的位置字段
表谢谢,tommyd456。这就是为什么我在这里,以避免糟糕的数据库设计!谢谢你的建议