# Database design

**URL:** <https://www.ruby-forum.com/t/database-design/181849>\
**Category:** Rails\
**Created:** [January 19, 2010, 7:47am UTC](https://www.ruby-forum.com/t/database-design/181849 "2010-01-19T07:47:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek\_shukla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7cd45c/32.png) [@Abhishek\_shukla](https://www.ruby-forum.com/u/Abhishek_shukla)\
**Post date:** [January 19, 2010, 7:47am UTC](https://www.ruby-forum.com/t/database-design/181849/1 "2010-01-19T07:47:08Z")

</div>

Hello Friends,  
I just wanted to know the proper way of designing a database which  
should  
be worked with the activerocord design.  
My requirement is

I have 100’s of question and answer to that question, and the scenario  
is  
that a user will select the answer which will be used for the future  
reference.  
As we have to keep in mind that the answer can be in any format like - a  
number, text, date, datetime, checkbox, radiobutton.

So I have a YAML file to store the question and answer? Or it should in  
a  
database.,

So it will be very much helpful if you suggest me how should I design a  
Database on the above mentioned requirement.

Thanks  
Abhis.

---

<div class="post-metadata">

**Author:** ![Abhishek\_shukla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7cd45c/32.png) [@Abhishek\_shukla](https://www.ruby-forum.com/u/Abhishek_shukla)\
**Post date:** [January 19, 2010, 8:09am UTC](https://www.ruby-forum.com/t/database-design/181849/2 "2010-01-19T08:09:23Z")

</div>

Pluralised table names and id autoincrementing integer as your primary  
key. Use underscores between words all lowercase and foreign keys have  
singularised versions of the table name. For example great\_questions  
as a table name and great\_question\_id as a foreign key. Don’t use  
constraints if you can help it.

Blog: [http://random8.zenunit.com/](http://random8.zenunit.com/)  
Twitter: [http://twitter.com/random8r](http://twitter.com/random8r)  
Learn: [http://sensei.zenunit.com/](http://sensei.zenunit.com/)  
New video up now at [http://sensei.zenunit.com/](http://sensei.zenunit.com/) real fastcgi rails  
deploy process! Check it out now!

---

<div class="post-metadata">

**Author:** ![Abhishek\_shukla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7cd45c/32.png) [@Abhishek\_shukla](https://www.ruby-forum.com/u/Abhishek_shukla)\
**Post date:** [January 19, 2010, 8:56am UTC](https://www.ruby-forum.com/t/database-design/181849/3 "2010-01-19T08:56:23Z")

</div>

Julian L. wrote:

> Pluralised table names and id autoincrementing integer as your primary  
> key. Use underscores between words all lowercase and foreign keys have  
> singularised versions of the table name. For example great\_questions  
> as a table name and great\_question\_id as a foreign key.

Right.

> Don’t use  
> constraints if you can help it.

Fatally wrong! Constraints are essential to a database that will not be  
corrupted by inconsistent data. Do not leave them out.

> Blog: [http://random8.zenunit.com/](http://random8.zenunit.com/)  
> Twitter: [http://twitter.com/random8r](http://twitter.com/random8r)  
> Learn: [http://sensei.zenunit.com/](http://sensei.zenunit.com/)  
> New video up now at [http://sensei.zenunit.com/](http://sensei.zenunit.com/) real fastcgi rails  
> deploy process! Check it out now!

Best,  
–Â  
Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
