Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    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. COYes, I meant "has many :through =>". Also, yes, both associations have a join table, but I am basically wondering if it's a smart idea to use a primary table (in this case the BOOKS table) to try to act as the join table for AUTHORS and TOPICS. Does that clarify? To answer your question, I would think the BOOKS table would contain author_id and topics_id, and so each book could refer to authors and topics that way. I'm just wondering if I'm overusing HMT by cluttering up my BOOKS table (using it as the join)?
      singulars
    2. COYou can definitely do that. HMT doesn't check the content of the table, so as long as you have the right ids in there you can go nuts. All the HMT (and `:polymorphic` for that matter) does is set up the methods, so as long as you're careful about what you're putting where, you can get away with it. Even within the documentation, if an HMT is merely an HABTM that allows extra attributes (by being a discrete model), this can be reversed such that any model comprised of "extra attributes" can be a join model. Just add IDs!
      singulars
    3. CO@Eric, but if I put the join table in the BOOK table, don't I run into trouble if (for ex.) I have two authors who wrote that book? My Book model would have a unique entry for Book #1, given. It would then need to link to Author #1 _AS WELL AS_ Author #2, and where would the second entry go? Wouldn't the Book table entry simply have a single author_id integer key and a single topic_id key? In a HABTM you just repeat keys: i.e. 1-1, 1-2, 1-3 (for book #1 having three authors). But in my case my BOOKS table is already populated with entries, each representing a given book. ??
      singulars
 

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