【发布时间】:2018-05-18 07:14:33
【问题描述】:
我是 PostgreSQL 新手。我在父母和孩子之间的联系上有问题。 假设我们有两个模式,称为 TableA 和 TableB。 我需要关联 TableA 和 TableB。其中 TableA 的主键在 TableB 中可能需要也可能不需要用于“特定角色”(我有三个角色,称为 E、F 和 G。对于 G,我不需要 TableB 中的条目,但我需要它的其余部分角色)。我怎么关联。我需要使用哪个关联,has_many、has_one 等,有什么办法可以解决这个问题。你可以在这里找到链接Ecto Schema
TableA Schema
schema "TableA" do
field :name, :string
field :role, :string
field :status, :string
timestamps()
end
TableB Schema
schema "TableB" do
field :address1, :string
field :address2, :string
field :city, :string
field :companyname, :string
field :contactno, :string
field :country, :string
field :email, :string
field :mobileno, :string
field :state, :string
field :status, :string
field :type, :string
field :zipcode, :string
timestamps()
end
【问题讨论】:
标签: postgresql elixir phoenix-framework ecto