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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Koji Wakamiya
January 28, 2020
Technology
0
720
Room2.1 DatabaseView あるある
Koji Wakamiya
January 28, 2020
Tweet
Share
More Decks by Koji Wakamiya
See All by Koji Wakamiya
Flutterコントリビューションのススメ
d_r_1009
1
1k
人気サービスをFlutter Webでリプレースするとどうなるのか
d_r_1009
0
1.1k
モバイルアプリケーション 開発組織の“学び”
d_r_1009
0
390
Add-to-appの戦い方
d_r_1009
0
1.8k
開発チーム主導で iOSの新機能に対応する 3つのポイント
d_r_1009
0
690
FlutterKaigi2021
d_r_1009
0
1.8k
Flutter?
d_r_1009
0
440
AAC Paging & Kotlin化の紹介
d_r_1009
0
1.3k
JavaからKotlinに書き換えてハマる話
d_r_1009
0
7.8k
Other Decks in Technology
See All in Technology
Agentic Codingの実践とチームで導入するための工夫
lycorptech_jp
PRO
0
380
AI が Approve する開発フロー / How AI Reviewers Accelerate Our Development
zaimy
1
260
Webアクセシビリティ技術と実装の実際
tomokusaba
0
190
Snowflakeデータ基盤で挑むAI活用 〜4年間のDataOpsの基礎をもとに〜
kaz3284
1
330
Digitization部 紹介資料
sansan33
PRO
1
7k
Introduction to Bill One Development Engineer
sansan33
PRO
0
380
Databricksアシスタントが自分で考えて動く時代に! エージェントモード体験もくもく会
taka_aki
0
290
三菱UFJ銀行におけるエンタープライズAI駆動開発のリアル / Enterprise AI_Driven Development at MUFG Bank: The Real Story
muit
10
20k
Windows ネットワークを再確認する
murachiakira
PRO
0
230
Kaggleの経験が実務にどう活きているか / kaggle_findy
sansan_randd
1
150
primeNumber DATA MANAGEMENT CAMP #2:
masatoshi0205
1
670
組織のSREを推進するためのPlatform EngineeringとEKS / Platform Engineering and EKS to drive SRE in your organization
chmikata
0
180
Featured
See All Featured
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
83
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.2k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
470
Six Lessons from altMBA
skipperchong
29
4.2k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
660
4 Signs Your Business is Dying
shpigford
187
22k
GraphQLとの向き合い方2022年版
quramy
50
14k
How Software Deployment tools have changed in the past 20 years
geshan
0
32k
A Tale of Four Properties
chriscoyier
162
24k
Utilizing Notion as your number one productivity tool
mfonobong
4
240
Testing 201, or: Great Expectations
jmmastey
46
8.1k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
63
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!