【发布时间】:2016-09-10 15:47:22
【问题描述】:
我的数据库中有两个实体都需要地址。每个 ID 都可以有一个地址。
场地表:
create_table "venues", force: :cascade do |t|
t.string "name"
t.text "description"
t.string "email"
t.string "phone"
t.integer "category_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
用户表
create_table "users", force: :cascade do |t|
t.string "first_name"
t.string "surname"
t.string "email"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
场所的地址表有两列,用户不需要。纬度和经度列。
在这种情况下,创建一个带有用户外键的地址表和其他带有场地外键的地址表是一个好方法吗?什么是最好的解决方案?
【问题讨论】:
标签: mysql ruby-on-rails database database-design polymorphic-associations