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

RDBアンチパターン

soudai sone
November 03, 2016

 RDBアンチパターン

PHPカンファレンス2016の資料です

http://phpcon.php.gr.jp/2016/

soudai sone

November 03, 2016
Tweet

More Decks by soudai sone

Other Decks in Technology

Transcript

  1. JE OBNF BHF EFMFUF@qBH  TPOF    TPVEBJ

       UBLFUPNP    TPOF  
  2. JE OBNF BHF EFMFUF@qBH  TPOF    TPVEBJ

       UBLFUPNP    TPOF   ࡟আͱݴ͏ঢ়ଶΛϑϥάͰදݱ
  3. Ӆ͞Εͨঢ়ଶ $user = $this->get_user($user_id); if ($user->get(‘delete_falg’) == 1) { //

    ࡟আࡁΈͷϢʔβͷॲཧ return } σʔλͷதͷঢ়ଶ͸ΞϓϦέʔγϣϯ ͸औΓग़͢·ͰΘ͔Βͳ͍
  4. ച্ JE ച্ֹۚ ച্೔ ഑ૹঢ়ଶ     ഑ૹࡁ

       ൃ஫த ộ ộ ộ ച্JE ঎඼JE ݸ਺ ߪೖऀ    TPOF    TPOF    TPOF    TPOF ঎඼JE ঎඼໊ Ձ֨  42-࣮ફೖ໳    Ϧʔμϒϧίʔυ    ϓϩάϥϚͷͨΊͷ42-    σʔλϕʔεɾϦϑΝΫλϦϯά   ঎඼ Χʔτ ച্
  5. ച্JE ঎඼JE ݸ਺ ߪೖऀ    TPOF  

     TPOF    TPOF    TPOF ঎඼JE ঎඼໊ Ձ֨  42-࣮ફೖ໳    Ϧʔμϒϧίʔυ    ϓϩάϥϚͷͨΊͷ42-    σʔλϕʔεɾϦϑΝΫλϦϯά   ঎඼ ച্ ച্ JE ച্ֹۚ ച্೔ ഑ૹঢ়ଶ     ഑ૹࡁ    ൃ஫த ộ ộ ộ Χʔτ
  6. ച্JE ঎඼JE ݸ਺ ߪೖऀ    TPOF  

     TPOF    TPOF    TPOF ঎඼JE ঎඼໊ Ձ֨  42-࣮ફೖ໳    Ϧʔμϒϧίʔυ    ϓϩάϥϚͷͨΊͷ42-    σʔλϕʔεɾϦϑΝΫλϦϯά   ঎඼ ച্ ച্ JE ച্ֹۚ ച্೔ ഑ૹঢ়ଶ     ഑ૹࡁ    ൃ஫த ộ ộ ộ ফඅ੫ͷঢ়ଶ͕ӅΕͯΔ ͱ͕೔෇ͰมΘΔ Χʔτ
  7. ച্JE ঎඼JE ݸ਺ ߪೖऀ    TPOF  

     TPOF    TPOF    TPOF ঎඼JE ঎඼໊ Ձ֨  42-࣮ફೖ໳    Ϧʔμϒϧίʔυ    ϓϩάϥϚͷͨΊͷ42-    σʔλϕʔεɾϦϑΝΫλϦϯά   ঎඼ ച্ ച্ JE ച্ֹۚ ച্೔ ഑ૹঢ়ଶ     ഑ૹࡁ    ൃ஫த ộ ộ ộ ͍ͭ഑ૹঢ়ଶ͕ มΘ͔ͬͨΘ͔Βͳ͍ Χʔτ
  8. ച্JE ঎඼JE ݸ਺ ߪೖऀ    TPOF  

     TPOF    TPOF    TPOF ঎඼JE ঎඼໊ Ձ֨  42-࣮ફೖ໳    Ϧʔμϒϧίʔυ    ϓϩάϥϚͷͨΊͷ42-    σʔλϕʔεɾϦϑΝΫλϦϯά   ঎඼ ച্ ച্ JE ച্ֹۚ ച্೔ ഑ૹঢ়ଶ     ഑ૹࡁ    ൃ஫த ộ ộ ộ Χʔτ
  9. ച্JE ঎඼JE ݸ਺ ߪೖऀ    TPOF  

     TPOF    TPOF    TPOF ঎඼JE ঎඼໊ Ձ֨  42-࣮ફೖ໳    Ϧʔμϒϧίʔυ    ϓϩάϥϚͷͨΊͷ42-    σʔλϕʔεɾϦϑΝΫλϦϯά   ঎඼ ച্ ঎඼໊͕มΘͬͨΒʁ Ձ֨Λม͑ͨΒʁ ച্ͷࣄ࣮ͱෆ੔߹͕ੜ·ΕΔ ച্ JE ച্ֹۚ ച্೔ ഑ૹঢ়ଶ     ഑ૹࡁ    ൃ஫த ộ ộ ộ Χʔτ
  10. ച ্ ച্ۚ ֹ ফඅ੫ ফඅ੫ֹ ച্೔   

            ộ ộ ộ ফඅ੫ ച্ ച্JE ഑ૹঢ়ଶ ࡞੒೔࣌  ൃ஫த   ഑ૹத   ೲ඼ࡁ   ൃ஫த  ফඅ੫ ༗ޮ೔ ࣦޮ೔      OVMM ഑ૹঢ়گ
  11. ച ্ ച্ۚ ֹ ফඅ੫ ফඅ੫ֹ ച্೔   

            ộ ộ ộ ফඅ੫ ച্ ച্JE ഑ૹঢ়ଶ ࡞੒೔࣌  ൃ஫த   ഑ૹத   ೲ඼ࡁ   ൃ஫த  ফඅ੫ ༗ޮ೔ ࣦޮ೔      OVMM ഑ૹঢ়گ ഑ૹঢ়گͷཤྺΛ࣋ͭ ߋ৽Ͱ͸ແ͘௥ՃͰྺ࢙Λ࡞Δ
  12. ച ্ ച্ۚ ֹ ফඅ੫ ফඅ੫ֹ ച্೔   

            ộ ộ ộ ফඅ੫ ച্ ച্JE ഑ૹঢ়ଶ ࡞੒೔࣌  ൃ஫த   ഑ૹத   ೲ඼ࡁ   ൃ஫த  ফඅ੫ ༗ޮ೔ ࣦޮ೔      OVMM ഑ૹঢ়گ ಉ༷ʹফඅ੫ͷྺ࢙Λ࣋ͭ ฦ඼࣌ͷ෷͍໭͠ͷॲཧͷ࣌ͳͲ Ͱ࣋ͬͯͳ͍ͱࢮ͵
  13. ച ্ ച্ۚ ֹ ফඅ੫ ফඅ੫ֹ ച্೔   

            ộ ộ ộ ফඅ੫ ച্ ച্JE ഑ૹঢ়ଶ ࡞੒೔࣌  ൃ஫த   ഑ૹத   ೲ඼ࡁ   ൃ஫த  ফඅ੫ ༗ޮ೔ ࣦޮ೔      OVMM ഑ૹঢ়گ ಉ༷ʹফඅ੫ͷྺ࢙Λ࣋ͭ ฦ඼࣌ͷ෷͍໭͠ͷॲཧͷ࣌ͳͲ Ͱ࣋ͬͯͳ͍ͱࢮ͵ 1PTUHSF42-ͷൣғܕΛ࢖͏ͱ༗ޮൣғ ΛεϜʔζʹॲཧग़དྷΔ
  14. ച ্ ച্ۚ ֹ ফඅ੫ ফඅ੫ֹ ച্೔   

            ộ ộ ộ ফඅ੫ ച্ ച্JE ഑ૹঢ়ଶ ࡞੒೔࣌  ൃ஫த   ഑ૹத   ೲ඼ࡁ   ൃ஫த  ফඅ੫ ༗ޮ೔ ࣦޮ೔      OVMM ഑ૹঢ়گ ܭࢉͨ͠ΒಘΔࣄ͕ग़དྷΔ ඇਖ਼نԽͷҰͭ ύϑΥʔϚϯεͱ૬ஊ
  15. ച ্ ച্ۚ ֹ ফඅ੫ ফඅ੫ֹ ച্೔   

            ộ ộ ộ ফඅ੫ ച্ ച্JE ഑ૹঢ়ଶ ࡞੒೔࣌  ൃ஫த   ഑ૹத   ೲ඼ࡁ   ൃ஫த  ফඅ੫ ༗ޮ೔ ࣦޮ೔      OVMM ഑ૹঢ়گ ܭࢉͨ͠ΒಘΔࣄ͕ग़དྷΔ ඇਖ਼نԽͷҰͭ ύϑΥʔϚϯεͱ૬ஊ .Z42-ͷԾ૝ྻΛར༻͢Δͱ ΑΓΩϨΠʹ࣮૷ग़དྷΔ
  16. ϩοΫͷޭࡑ τϥϯβΫγϣϯ෼཭Ϩϕϧ ໊લ ෼཭Ϩϕϧ આ໌ 4&3*"-*;"#-& ͍ͭ͞Α ௚ྻతʹॲཧ 3&1&"5"#-&3&"% ڧ͍

    ಡΈऔΓର৅ͷσʔλ ΛৗʹಡΈऔΔ 3&"%$0..*55&% ·͊·ڧ͍ ֬ఆͨ͠࠷৽σʔλΛ ৗʹಡΈऔΔ 3&"% 6/$0..*55&% ऑ͍ ଞͷॲཧʹΑͬͯߦΘ Ε͍ͯΔɺॻ͖͔͚ͷ σʔλ·ͰಡΈऔΔɻ
  17. ϩοΫͷޭࡑ τϥϯβΫγϣϯ෼཭Ϩϕϧ ໊લ ෼཭Ϩϕϧ આ໌ 4&3*"-*;"#-& ͍ͭ͞Α ௚ྻతʹॲཧ 3&1&"5"#-&3&"% ڧ͍

    ಡΈऔΓର৅ͷσʔλ ΛৗʹಡΈऔΔ 3&"%$0..*55&% ·͊·ڧ͍ ֬ఆͨ͠࠷৽σʔλΛ ৗʹಡΈऔΔ 3&"% 6/$0..*55&% ऑ͍ ଞͷॲཧʹΑͬͯߦΘ Ε͍ͯΔɺॻ͖͔͚ͷ σʔλ·ͰಡΈऔΔɻ .Z42-ͷσϑΥϧτ͸͜͜
  18. ϩοΫͷޭࡑ τϥϯβΫγϣϯ෼཭Ϩϕϧ ໊લ ෼཭Ϩϕϧ આ໌ 4&3*"-*;"#-& ͍ͭ͞Α ௚ྻతʹॲཧ 3&1&"5"#-&3&"% ڧ͍

    ಡΈऔΓର৅ͷσʔλ ΛৗʹಡΈऔΔ 3&"%$0..*55&% ·͊·ڧ͍ ֬ఆͨ͠࠷৽σʔλΛ ৗʹಡΈऔΔ 3&"% 6/$0..*55&% ऑ͍ ଞͷॲཧʹΑͬͯߦΘ Ε͍ͯΔɺॻ͖͔͚ͷ σʔλ·ͰಡΈऔΔɻ 1PTUHSF42- 0SBDMF%# 42-4FSWFS ͷσϑΥϧτ͸͜͜
  19. ϩοΫͷޭࡑ τϥϯβΫγϣϯ෼཭Ϩϕϧ ໊લ ෼཭Ϩϕϧ આ໌ 4&3*"-*;"#-& ͍ͭ͞Α ௚ྻతʹॲཧ 3&1&"5"#-&3&"% ڧ͍

    ಡΈऔΓର৅ͷσʔλ ΛৗʹಡΈऔΔ 3&"%$0..*55&% ·͊·ڧ͍ ֬ఆͨ͠࠷৽σʔλΛ ৗʹಡΈऔΔ 3&"% 6/$0..*55&% ऑ͍ ଞͷॲཧʹΑͬͯߦΘ Ε͍ͯΔɺॻ͖͔͚ͷ σʔλ·ͰಡΈऔΔɻ 1PTUHSF42- 0SBDMF%# 42-4FSWFS ͷσϑΥϧτ͸͜͜ ϑΝϯτϜϦʔυ΍μʔςΟϦʔυͳͲͷ࿩͸ࠓ೔͸͠·ͤΜ ʮ͑ʁͳʹͦΕʯͬͯਓ͸ࠓ͙͢άάοͯษڧͨ͠ํ͕͍͍Ͱ͢
  20. ϩοΫͷޭࡑ ओͳϩοΫͷछྨ w ഉଞ F9DMVEFE ϩοΫ w ڞ༗ 4IBSFE ϩοΫ

    ϩοΫର৅ʹରͯ͠ɺଞͷΞΫηεΛҰ੾ېࢭ͢Δ ଞͷΞΫηε͸ߋ৽ɾ࡟আɾࢀরશͯग़དྷͳ͍ ॻ͖ࠐΈϩοΫͱݺ͹ΕΔࣄ΋͋Δ
  21. ϩοΫͷޭࡑ ओͳϩοΫͷछྨ w ഉଞ F9DMVEFE ϩοΫ w ڞ༗ 4IBSFE ϩοΫ

    ϩοΫର৅ʹରͯ͠ɺࢀরҎ֎ͷॲཧΛېࢭ͢Δ ଞͷΞΫηε͸ࢀর 4&-&$5 Λ͢Δ͜ͱ͕ग़དྷΔ ಡΈࠐΈϩοΫͱݺ͹ΕΔࣄ΋͋Δ