Room2.1 DatabaseView あるある
by
Koji Wakamiya
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
Room2.1 DatabaseView ͋Δ͋Δ ͋Δ͋ΔLTʙ ͓ਖ਼݄ͩΑʂAndroid & iOS߹ಉ େLTେձ ʙ Vol.10
Slide 2
Slide 2 text
ࣗݾհ • Koji Wakamiya • Studyplus, inc. • @koji-1009 (Github) • @D_R_1009 (Twitter, Hatena, etc…)
Slide 3
Slide 3 text
DatabaseView ͬͯ·͔͢ʁ
Slide 4
Slide 4 text
DatabaseViewʹ͍ͭͯʢ͓͞Β͍ʣ • Room 2.1ͰՃ͞Εͨػೳ • Inner/Outer joinΛRoomͰ࣮ݱ • ςʔϒϧΛ͋Δ͖ܗʹׂ͠ දࣔ(View)ʹ߹ΘͤͯσʔλΛ߹͢Δ͜ͱ͕Ͱ͖Δ
Slide 5
Slide 5 text
ෳͷςʔϒϧͱForeignKey • ؔ࿈ͷ͋ΔෳͷςʔϒϧΛѻ͏͜ͱʹͳΔͨΊ ForeignKeyΛར༻͢Δ͜ͱ͕͋Δ • ؔ࿈͚Λߦ͏͜ͱͰɺத৺ͱͳΔrowΛআͨ࣌͠ʹ ଞͷςʔϒϧͷrowআ͢ΔͳͲͷߟྀΛߦ͏
Slide 6
Slide 6 text
OnConflictStrategy.REPLACEͰ σʔλ͕ফ͑ͪΌ͏ࣄ݅
Slide 7
Slide 7 text
OnConflictStrategy • InsetॲཧதʹConflict͕ൃੜ(row͕طʹଘࡏ)ͨ࣌͠ ͲͷΑ͏ͳѻ͍Λ͢Δ͔ΛܾΊΔ͜ͱ͕Ͱ͖Δ • DBͷར༻༻్తʹ߹Θͤͯར༻͢ΔStrategy͕มΘΔ
Slide 8
Slide 8 text
OnConflictStrategy • ABORT (default) • OnConflict strategy constant to abort the transaction. • REPLACE • OnConflict strategy constant to replace the old data and continue the transaction. • Ignore • OnConflict strategy constant to ignore the conflict.
Slide 9
Slide 9 text
ࣄ݅ঢ়گ • ΞΠςϜςʔϒϧͱΞΠςϜฒͼॱςʔϒϧ͕ଘࡏ • ΞΠςϜΞϓϦىಈ࣌ʹαʔόʔͱಉظ • @InsertͱOnConflictStrategy.REPLACEͰશσʔλߋ৽ • ฒͼॱͷσʔλΞϓϦʹ͔͠ଘࡏ͠ͳ͍ͨΊอ࣋
Slide 10
Slide 10 text
ࣄ݅ঢ়گ • αʔόʔͱΞϓϦDBΛಉظ(ϦϑϨογϡ)͢Δͱ ΞΠςϜϦετ͕දࣔ͞Εͳ͘ͳΔ • ௐͯΈΔͱʮΞΠςϜʯͷσʔλ͋Δ͕ ʮΞΠςϜฒͼॱʯ͕ଘࡏ͠ͳ͘ͳ͍ͬͯΔ • Inner JoinͷͨΊDatabaseView͕ੜ͞Ε͍ͯͳ͍……ʁ
Slide 11
Slide 11 text
Ͳ͏ͯ͠σʔλফ͑ͪΌ͏Μ……
Slide 12
Slide 12 text
REPLACEʹΑΔUpdateॲཧ • REPLACE࣮࣭తʹUpdateॲཧʢͩͱࢥ͍ͬͯͨʣ • Conflictൃੜ͠ͳ͍ → ৽نrow࡞ॲཧ • Conflictൃੜ͢Δ → طଘrowߋ৽ॲཧ
Slide 13
Slide 13 text
REPLACEʹΑΔUpdateॲཧ • REPLACE࣮࣭తʹUpdateॲཧʢͰͳ͍ʣ • Conflictൃੜ͠ͳ͍ → ৽نrow࡞ॲཧ • Conflictൃੜ͢Δ → طଘrowߋ৽ॲཧ طଘrowআॲཧ + ৽نrowՃॲཧ
Slide 14
Slide 14 text
REPLACEʹΑΔUpdateॲཧ • طଘrowͷআ + ForeignKeyʹΑΔؔ࿈͚ʹΑΓ ʮΞΠςϜʯͷআͰʮΞΠςϜฒͼॱʯ͕আ͞Ε͍ͯͨ • @InsertͰͳ͘@UpdateΛར༻͠ͳ͚ΕͳΒͳ͔ͬͨ • Ճͱߋ৽ॲཧΛϝιουͰΓ͚Δ͜ͱͰ ͜ͱͳ͖ΛಘΔ͜ͱ͕Ͱ͖ͨ
Slide 15
Slide 15 text
υΩϡϝϯτͪΌΜͱಡΉ ʢ͋ͱɺԣண͠ͳ͍ʣ
Slide 16
Slide 16 text
Thanks!