12

I know there are many database design tool, database modeling tool. Example, ER-win , db desginer and etc.

But, they are not supported for Ruby on Rails.

What is the best way or tool to design database for Ruby on Rails?

Appended:

I know the rails development phases are growing step by step. But, When starting of project, I think database modeling has to be first. Which database modeling tool can I use?

5 Answers 5

15

You're working at it backwards. Don't figure out the table structure you need, then build your application around it. The Rails Way is to start building your application's functionality, piece by piece, and add migrations to build up your database as you need it.

You'll end up with a simpler data model, nothing you don't need, and your data structure will reflect the interactions people have with your site instead of the other way around.

2
  • Just here to say thank you for this answer.. you made my day, and saved a whole week of search on best data modeling tool for RoR
    – Hesham
    Aug 18, 2014 at 17:09
  • Still holds up even all those years later Mar 31, 2021 at 4:26
8

With Rails, you don't. You design the object model, the database model is generated. All database handling is done in the model.

1
  • Long time ago, when there was no migration we create the database first, because Rails is using the active record pattern and hardly nothing is written on the model. Oct 22, 2009 at 6:43
4

With Rails you use migrations to design your database. Give migrations a shot - I thought I would miss the diagrams in SQL Server when I started working with Rails but I don't.

You can see your schema in a very readable text form at db/schema.rb

0

You can certainly use those tools to create your database, but without having experience with how rails deals with relationships you may run into trouble. Not that you can't work around the default way rails does things, but you'll make it a lot tougher on yourself.

So design your database, but know rails associations.

0

Like others have said, you should give migrations a shot. The Rails Getting Started guides are extremely helpful in explaining how this works.

http://guides.rubyonrails.org/getting_started.html

This one is specifically about migrations: http://guides.rubyonrails.org/active_record_migrations.html

Trying doing a basic migration, and you'll see it's incredibly easy. If you need to make changes or alter your migration, then check out that second link that covers more detail about migrations.

The Rails documentation is also pretty helpful for migrations: http://api.rubyonrails.org/classes/ActiveRecord/Migration.html

I know documentation on these things can sometimes be terrible, but in this case it's worth taking a look.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.