Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ERD_on_Rails.pdf

ogom
August 08, 2015
220

 ERD_on_Rails.pdf

ogom

August 08, 2015
Tweet

Transcript

  1. Example Domain ֓ཁʢՁ஋ʣ Ϣʔεέʔε ΦϒδΣΫτ ߦࣄ؅ཧγεςϜʢΠϕϯτΛ։࠵ͯ͠ɺίϛϡχςΟΛߏஙʣ · ར༻ऀ͸ίϛϡχςΟΛ૑ઃͰ͖Δɻ ར༻ऀ͸ίϛϡχςΟʹೖձͰ͖Δɻ ίϛϡχςΟʹೖձ͢ΔͱϝϯόʔʹͳΔɻ

    ίϛϡχςΟ͸ΠϕϯτΛ։࠵Ͱ͖Δɻ Πϕϯτ͸νέοτΛൃߦͰ͖Δɻ ϝϯόʔ͸νέοτೖखͰ͖Δɻ · · · · · · ར༻ऀ, ίϛϡχςΟ, ϝϯόʔ, Πϕϯτ, νέοτ · 3/10
  2. Domain Specific Language (DSL) Types આ໌ belongs_to ࢀর has_one ͻͱ͚ͭͩ࣋ͭ

    has_many ෳ਺࣋ͭ has_many through ... Λ௨ͯ͡ෳ਺࣋ͭ has_one through ... Λ௨ͯ͡ͻͱ͚ͭͩ࣋ͭ has_and_belongs_to_many ࢀরͱෳ਺࣋ͭ 5/10
  3. Generate 1 One-to-manyʢ1ରଟʣ One-to-Oneʢ1ର1ʣ $ rails generate scaffold group name

    $ rails generate scaffold event group:references has_many :events belongs_to :group $ rails generate scaffold policy group:references has_one :policy 6/10
  4. Generate 2 Many-to-manyʢଟରଟʣ Many-to-manyʢଟରଟʣ $ rails generate scaffold user name

    $ rails generate scaffold member user:references group:references has_many :members has_many :groups, through: :members has_many :users, through: :members $ rails generate scaffold ticket event:references member:references has_many :tickets has_many :events, through: :tickets has_many :members, through: :tickets 7/10