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
750
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Room2.1 DatabaseView あるある
Koji Wakamiya
January 28, 2020
More Decks by Koji Wakamiya
See All by Koji Wakamiya
Flutterコントリビューションのススメ
d_r_1009
1
1.3k
人気サービスをFlutter Webでリプレースするとどうなるのか
d_r_1009
0
1.2k
モバイルアプリケーション 開発組織の“学び”
d_r_1009
0
410
Add-to-appの戦い方
d_r_1009
0
1.9k
開発チーム主導で iOSの新機能に対応する 3つのポイント
d_r_1009
0
720
FlutterKaigi2021
d_r_1009
0
1.9k
Flutter?
d_r_1009
0
460
AAC Paging & Kotlin化の紹介
d_r_1009
0
1.4k
JavaからKotlinに書き換えてハマる話
d_r_1009
0
7.8k
Other Decks in Technology
See All in Technology
「ちゃんとやっている」は独りよがりだった ― 不安に寄り添うインシデント対応へ / Towards incident response that addresses anxieties
chmikata
1
290
LiDAR SLAMの実装とセンサ融合 ~Lie群からContinuous-Time LIOまで~
naokiakai
1
910
記録をかんたんに、提案をパーソナルに ── AIであすけんが目指すもの
oprstchn
0
130
飲食店もAIで。レジ締めやハンディシステムをつくってる話 / Using AI for restaurant management
vtryo
0
230
本当の”仕事”を手放せる未来が見えた
mu7889yoon
0
220
Claude Codeとハーネスについて考えてみる
oikon48
15
6.7k
product engineering with qa
nealle
0
140
Why is RC4 still being used?
tamaiyutaro
0
280
AIに障害切り分けを全部やってもらった。 。 。 。
estie
0
340
AI駆動開発におけるQAエンジニアの役割事例 〜AI駆動開発の現場から〜
kobayashiyorimitsu
0
290
アラート調査向けAIエージェントの本番導入とその後/AI Agents for Alert Investigation: Production Deployment and After
taddy_919
1
330
そのタスクオンスケですか?
poropinai1966
0
120
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Ruling the World: When Life Gets Gamed
codingconduct
0
270
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
Embracing the Ebb and Flow
colly
88
5.1k
Facilitating Awesome Meetings
lara
57
7k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
880
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
180
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Deep Space Network (abreviated)
tonyrice
0
220
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
180
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
480
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!