Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have used almost all your suggested options. While I would eliminate options A, B and D for the following reasons, I can't talk about C because I don't know <code>hstore</code> and don't use Postgres:</p> <ul> <li>Option A: <strong>Separate tables</strong>, as you said, would be very difficult to maintain. Each time you would want to change the structure of <strong>events</strong>, you'd have to do it on all the <strong>sub_events</strong> tables.</li> <li>Option B: <strong>Single table inheritance</strong>, I have used it a lot and dropped it. I felt like a big design drawback between what you see in the database and what your models look like. Lots of nil fields also.</li> <li>Option D: <strong>events table with polymorphic link to *_event_data</strong>. Polymorphic tables are not meant for that purpose. They are a way to have different <code>type</code> fields in a model so you could reference it without specifying the type explicitly.</li> </ul> <p>Option E seems OK, but where the foreign key should be stored? Hard to tell and may lead to difficult to maintain situations.</p> <p>Personally, I would go with <strong>the code I want to write</strong>, what would make using it and reading it later easier. I like things when they are more specific. And I would simply change the way I name my models so that it satisfies my needs. You have to be creative!</p> <p>I would rather write something like that:</p> <pre><code>conference.event_information.users OR sales_event.settings.title OR interview.shared_information.comments OR event.interview_details.starting_at </code></pre> <p>With all that examples, I'd use classical <code>has_many</code> and <code>belongs_to</code> relationships.</p> <p>I think that the whole concept of data types and inheritance can put you in situations where it does not solve problems or make things clearer. Sometimes you just need to see things a little differently.</p> <p>I hope it helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload