# Model Design question in Rails

**URL:** <https://www.ruby-forum.com/t/model-design-question-in-rails/119545>\
**Category:** Rails\
**Created:** [November 7, 2007, 8:39pm UTC](https://www.ruby-forum.com/t/model-design-question-in-rails/119545 "2007-11-07T20:39:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![raghus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@raghus](https://www.ruby-forum.com/u/raghus)\
**Post date:** [November 7, 2007, 8:39pm UTC](https://www.ruby-forum.com/t/model-design-question-in-rails/119545/1 "2007-11-07T20:39:07Z")

</div>

I have a site which has both articles and photos embedded in each  
article. I want to allow people to comment on both a particular  
article itself as well as on an individual photo in an article.

My questions is: What’s the best design for the DB model - one  
Comments table with a flag to say if the comment was on an article or  
a photo or two separate tables - one for comments on articles and the  
other for comments on articles? What’s a good naming convention for  
these tables?

I realize there may be no single correct answer but I am hoping to get  
some good suggestions/ideas.

---

<div class="post-metadata">

**Author:** ![raghus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@raghus](https://www.ruby-forum.com/u/raghus)\
**Post date:** [November 7, 2007, 8:41pm UTC](https://www.ruby-forum.com/t/model-design-question-in-rails/119545/2 "2007-11-07T20:41:29Z")

</div>

I’ll correct some spellos first

1. My question is…
2. One for comments on articles and the other for comments on photos.

---

<div class="post-metadata">

**Author:** ![raghus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@raghus](https://www.ruby-forum.com/u/raghus)\
**Post date:** [November 7, 2007, 10:21pm UTC](https://www.ruby-forum.com/t/model-design-question-in-rails/119545/3 "2007-11-07T22:21:49Z")

</div>

Have you looked into polymorphic associations?

Fred
