开发者

What table fields would I need here?

开发者 https://www.devze.com 2023-02-21 21:23 出处:网络
I want to create a commenting model with a twist. I want there to be multiple commenting columns like on hunch.com, except that a user can decide how many columns there should be. Also, a user can dec

I want to create a commenting model with a twist. I want there to be multiple commenting columns like on hunch.com, except that a user can decide how many columns there should be. Also, a user can decide the title for each column.

This is rather dynamic, so how would I set up my tables f开发者_StackOverflow中文版or this?


Seems like a perfect use case for NoSQL. I'd use something like CouchDB or Mongo here. Since there you don't have a schema you can add the attributes as needed.


Since you cannot really change the attributes of a model, if you want to create dynamic model attributes, you can have 3 models :

User
Attribute
UserAttribute

Now, you can add as many attributes are you want (Attribute is the static representation of an attribute). Then, a user can have many attributes through user_attributes.

0

精彩评论

暂无评论...
验证码 换一张
取 消