Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I wrote the (not production ready) beginnings of an ORM that would do exactly what you're looking for a while back. Just so that I could have a proof of concept. All my studies did yield that you're in some way mixing code and data (subclass information in the liquor table).</p> <p>So what you might do is write a method on your liquor class/table class that queries it's own table. The best way to get away with <strong>not having to hard-code all the subclasses in your liquor</strong> class is to have a column which contains the class name of the subclass in it.</p> <p>How you spread the details around is entirely up to you. I think the most normalized (and anyone can correct me if I'm wrong here) way to do it is to store all fields that appear in your liquor class in the liquor table. Then, for each subclass, have a table that stores the specific data that pertains to the subclass type. Which is the point at which you are mixing code and data because your code is reading the liquor table to get the name of the subclass to perform a join.</p> <p>I'll use cars &amp; bikes and some minimal, yet trivial differences between them for my example:</p> <pre><code>Ride ---- id name type (1, 'Sebring', 'Car') (2, 'My Bike', 'Bicycle') Bicycle ------- id bike_chain_length (2, '2 feet') Car --- id engine_size (1, '6 cylinders') </code></pre> <p>There's all kinds of variations from here forward like storing all liquor class data in the subclass table and only storing references and subclass names in the liquor table. I like this the least though because if you are aggregating the common data, it saves you from having to query every subclass table for the common fields.</p> <p>Hope this 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. This table or related slice is empty.
    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