如何设计像google base这样具有动态属性的系统? 在 Ruby on Rails 中
我想创建一个允许用户添加待售产品的应用程序。
我想让用户可以添加他/她喜欢的任何类型的产品,并让他们也为他们的产品创建存储和可搜索的属性 - 就像谷歌基地所做的那样。
有谁知道最好的方法来做到这一点,即对其进行建模。
我真的不想要每个类别都有一个表,因为这可能有 1000 个表。
做这个的最好方式是什么? 有人对此有好的/坏的经历吗?
有没有任何插件可以做到这一点?
任何帮助都会非常
感谢 里克
I am wanting to create an application that can allow users to add products for sale.
I want to make it so that a user can add whatever type of product he/she likes and let them also create stored and searchable attributes for their products - alot like google base does.
Does anyone know of the best way to do this ie model it.
I don't really want a table for each category as this would be possibly 1000s of tables.
What is the best way to do this? has anyone got good / bad experiences of this?
Is there any plugins that does this?
Any help would be great
thanks
rick
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来你想要的是一个标签系统。
如果您想要更灵活的东西,您可能需要考虑使用文档存储而不是数据库,例如 CouchDB。
It sounds like what you want is a tag system.
If you want something more flexible you might want to look at using a document store instead of a database, for example CouchDB.
如果您不想将其保留在关系数据库中,我建议创建一个名为“Descriptor”的模型,其中包含要添加的项目的 ID、属性“Color”的名称和值“Red”。
为了帮助保持一致,您还可以构建预设的描述符组(对于汽车:品牌、型号、颜色),并为值输入文本字段提供自动完成功能。
If you don't want to keep this in a relational database I'd suggest creating a Model called "Descriptor" that would contain the ID of the item being added, the name of the attribute "Color" and the value "Red".
To help keeps things consistent you could also structure pre-set groups of descriptors (for cars: make, model, color) as well as provide auto-completes for the value entry text fields.