Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Room2.1 DatabaseView あるある
Search
Koji Wakamiya
January 28, 2020
Technology
0
590
Room2.1 DatabaseView あるある
Koji Wakamiya
January 28, 2020
Tweet
Share
More Decks by Koji Wakamiya
See All by Koji Wakamiya
人気サービスをFlutter Webでリプレースするとどうなるのか
d_r_1009
0
870
モバイルアプリケーション 開発組織の“学び”
d_r_1009
0
260
Add-to-appの戦い方
d_r_1009
0
1.3k
開発チーム主導で iOSの新機能に対応する 3つのポイント
d_r_1009
0
530
FlutterKaigi2021
d_r_1009
0
1.5k
Flutter?
d_r_1009
0
340
AAC Paging & Kotlin化の紹介
d_r_1009
0
1.1k
JavaからKotlinに書き換えてハマる話
d_r_1009
0
7.5k
CircleCI + fastlaneで快適Androidアプリビルドの巻
d_r_1009
0
930
Other Decks in Technology
See All in Technology
Engineer Career Talk
lycorp_recruit_jp
0
120
20241120_JAWS_東京_ランチタイムLT#17_AWS認定全冠の先へ
tsumita
2
240
AWS Lambda のトラブルシュートをしていて思うこと
kazzpapa3
2
170
SSMRunbook作成の勘所_20241120
koichiotomo
2
130
Lambdaと地方とコミュニティ
miu_crescent
2
370
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
0
110
The Rise of LLMOps
asei
5
1.3k
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
120
社内で最大の技術的負債のリファクタリングに取り組んだお話し
kidooonn
1
550
第1回 国土交通省 データコンペ参加者向け勉強会③- Snowflake x estie編 -
estie
0
120
[FOSS4G 2019 Niigata] AIによる効率的危険斜面抽出システムの開発について
nssv
0
310
Featured
See All Featured
Happy Clients
brianwarren
98
6.7k
Music & Morning Musume
bryan
46
6.2k
Fireside Chat
paigeccino
34
3k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Faster Mobile Websites
deanohume
305
30k
How to train your dragon (web standard)
notwaldorf
88
5.7k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Transcript
Room2.1 DatabaseView ͋Δ͋Δ ͋Δ͋ΔLTʙ ͓ਖ਼݄ͩΑʂAndroid & iOS߹ಉ େLTେձ ʙ Vol.10
ࣗݾհ • Koji Wakamiya • Studyplus, inc. • @koji-1009 (Github)
• @D_R_1009 (Twitter, Hatena, etc…)
DatabaseView ͬͯ·͔͢ʁ
DatabaseViewʹ͍ͭͯʢ͓͞Β͍ʣ • Room 2.1ͰՃ͞Εͨػೳ • Inner/Outer joinΛRoomͰ࣮ݱ • ςʔϒϧΛ͋Δ͖ܗʹׂ͠ දࣔ(View)ʹ߹ΘͤͯσʔλΛ߹͢Δ͜ͱ͕Ͱ͖Δ
ෳͷςʔϒϧͱForeignKey • ؔ࿈ͷ͋ΔෳͷςʔϒϧΛѻ͏͜ͱʹͳΔͨΊ ForeignKeyΛར༻͢Δ͜ͱ͕͋Δ • ؔ࿈͚Λߦ͏͜ͱͰɺத৺ͱͳΔrowΛআͨ࣌͠ʹ ଞͷςʔϒϧͷrowআ͢ΔͳͲͷߟྀΛߦ͏
OnConflictStrategy.REPLACEͰ σʔλ͕ফ͑ͪΌ͏ࣄ݅
OnConflictStrategy • InsetॲཧதʹConflict͕ൃੜ(row͕طʹଘࡏ)ͨ࣌͠ ͲͷΑ͏ͳѻ͍Λ͢Δ͔ΛܾΊΔ͜ͱ͕Ͱ͖Δ • DBͷར༻༻్తʹ߹Θͤͯར༻͢ΔStrategy͕มΘΔ
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.
ࣄ݅ঢ়گ • ΞΠςϜςʔϒϧͱΞΠςϜฒͼॱςʔϒϧ͕ଘࡏ • ΞΠςϜΞϓϦىಈ࣌ʹαʔόʔͱಉظ • @InsertͱOnConflictStrategy.REPLACEͰશσʔλߋ৽ • ฒͼॱͷσʔλΞϓϦʹ͔͠ଘࡏ͠ͳ͍ͨΊอ࣋
ࣄ݅ঢ়گ • αʔόʔͱΞϓϦDBΛಉظ(ϦϑϨογϡ)͢Δͱ ΞΠςϜϦετ͕දࣔ͞Εͳ͘ͳΔ • ௐͯΈΔͱʮΞΠςϜʯͷσʔλ͋Δ͕ ʮΞΠςϜฒͼॱʯ͕ଘࡏ͠ͳ͘ͳ͍ͬͯΔ • Inner JoinͷͨΊDatabaseView͕ੜ͞Ε͍ͯͳ͍……ʁ
Ͳ͏ͯ͠σʔλফ͑ͪΌ͏Μ……
REPLACEʹΑΔUpdateॲཧ • REPLACE࣮࣭తʹUpdateॲཧʢͩͱࢥ͍ͬͯͨʣ • Conflictൃੜ͠ͳ͍ → ৽نrow࡞ॲཧ • Conflictൃੜ͢Δ →
طଘrowߋ৽ॲཧ
REPLACEʹΑΔUpdateॲཧ • REPLACE࣮࣭తʹUpdateॲཧʢͰͳ͍ʣ • Conflictൃੜ͠ͳ͍ → ৽نrow࡞ॲཧ • Conflictൃੜ͢Δ →
طଘrowߋ৽ॲཧ طଘrowআॲཧ + ৽نrowՃॲཧ
REPLACEʹΑΔUpdateॲཧ • طଘrowͷআ + ForeignKeyʹΑΔؔ࿈͚ʹΑΓ ʮΞΠςϜʯͷআͰʮΞΠςϜฒͼॱʯ͕আ͞Ε͍ͯͨ • @InsertͰͳ͘@UpdateΛར༻͠ͳ͚ΕͳΒͳ͔ͬͨ • Ճͱߋ৽ॲཧΛϝιουͰΓ͚Δ͜ͱͰ
͜ͱͳ͖ΛಘΔ͜ͱ͕Ͱ͖ͨ
υΩϡϝϯτͪΌΜͱಡΉ ʢ͋ͱɺԣண͠ͳ͍ʣ
Thanks!