Hi,

I'm trying to figure out the right way to implement this scenario in Sequel:

Objects - 
Addresses:
address_id - Primary Key
typical address fields...

Warehouses:
warehouse_id - Primary Key
shipping_address_id - Foreign Key to Addresses
returns_address_id - Foreign Key to Addresses

Can I just do this:
class Warehouse < Sequel::Model
  many_to_one :shipping_address, key: :shipping_address_id, class: Address
  many_to_one : returns_address, key: : returns_address_id, class: Address
end

Also, will this work for DDL:
    create_table(:addresses) do
      Integer :address_id, primary_key: true
    end
    create_table(:warehouses) do
      Integer :warehouse_id, primary_key: true
      foreign_key :shipping_address_id, :addresses, null: false
      foreign_key :returns_address_id, :addresses
    end

Thanks!!
Mason

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/6585b971-9a8c-4bff-8ecc-b262a43b8227%40googlegroups.com.

Reply via email to