Adding a user_id to the book_locations table should be good enough.
Also, what is the locations table giving you here? looks to me like
there could be a column :location in :book_locations instead
of :location_id. The :book_locations would basically become the join
table in a many to many relation ship of :users and :books. My
understanding here is that :book_locations should identify one book
checkout which includes the checked out book, the user and some extra
information related to a book checkout.

I also understand that :locations could be a session where the user
comes in and checks out a few books at a time and
every :book_locations is to identify which books were checked out in
that session. If that is the case, then I would add the
column :user_id to the :locations table because all the books assigned
to that :location_id should be from the same user.

Hopefully that helps.

exploid

On Jul 19, 2:04 pm, Scott LaBounty <[email protected]> wrote:
> A while back I had a couple of questions on join tables with additional
> columns and I got quite a bit of help here. I'm still working on the library
> app in Ramaze and I'm stuck on a piece of the design that I hope someone(s)
> here can help with. Here's my tables (the relevant ones anyway).
>
>         create_table(:users) do
>             primary_key :id
>             String :user_name
>             String :password
>             String :email
>         end
>
>         create_table(:books) do
>             primary_key :id
>             String :title
>         end
>         create_table(:locations) do
>             primary_key :id
>             String :location
>         end
>
>         create_table(:book_locations) do
>             primary_key :id
>             foreign_key :location_id, :locations
>             foreign_key :book_id, :books
>             Integer :total
>             Integer :checked_out
>         end
>     end
>
> Now I want to add a way to connect the users with the books they've checked
> out. Should I add a join table between users and the book_locations table?
> If so, what's the best way of doing that? If not, what's a better approach?
>
> Thanks for all the help.
>
> --
> Scotthttp://steamcode.blogspot.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to