What are the consequences of too many unnecessary associations in rails database?

123 Views Asked by At

Sometimes it feels natural or is at least tempting to make model associations based on columns that can be associated. But that doesn't mean they should be associated.

What price does a database/app pay if there are too many unnecessary model associations?

What I know so far is that when we do something like user:references it creates a foreign key (and index on that key). So my guess is that it would be possible to bloat the database. But I have no idea how likely that is?

Minimal example

Suppose we have an airbnb type app, with hosts and guests. Suppose the Payment model records the host id and guest id in that table (technically it doesn't need to, since it would already associate with a Booking, which would already have the host and guest).

So in terms of app functionality, the Payment table doesn't need to have associations with the Host and Guest tables, but it could.

In circumstances where an association might create some conveniences, but is definitely not essential to the app, should we create the association?

0

There are 0 best solutions below