Firebase database storing into sqlite database with some properties unchanged
Okay so my app database is completely stored on firebase,
and my app updates its database every day.
What procedure i used to follow everytime during updating the data:
- Drop the current sqlite table
- Create the table again
- Fill in the data
This used to work perfectly, imagine a row is deleted so as i drop the whole table and rewrite the whole thing, the deleted row also get technically deleted from the local sqlite,But now there is a slight change in the table, there is a column, say "viewed" which stores if the particular row data is viewed or not, "true" or "false" (String)
Now if i drop the data while updating, it'll lose this column properties.
Then i thought of using UPDATE in sqlite and update the data of the columns of each row, but then there might be instances when a particular column is no more in the firebase, but if i do this, it will remain in my local database. (I mean that data is not edited but deleted). So how can i overcome this ?
Old Table :
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_videos (id TEXT, link TEXT, title TEXT, subcode TEXT)");
New Table :
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_videos (id TEXT, link TEXT, title TEXT, subcode TEXT, viewed TEXT)");
P.S. I am using firebase single time listener as i need to update data only once daily.
I used to run this function everytime i wanted to clear the database :
public void clearDB()
{
db.execSQL("DROP TABLE IF EXISTS subCodes");
db.execSQL("CREATE TABLE IF NOT EXISTS subCodes (id TEXT, dbName TEXT, subName TEXT, tagline TEXT, pref INTEGER, hasInterviewQuestions TEXT, hasVideos TEXT, hasCodes TEXT)");
db.execSQL("DROP TABLE IF EXISTS appdata_codes");
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_codes (id TEXT, question TEXT, code TEXT, tag TEXT, subcode TEXT, imglink TEXT, xlink TEXT)");
db.execSQL("DROP TABLE IF EXISTS appdata_videos");
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_videos (id TEXT, link TEXT, title TEXT, subcode TEXT)");
db.execSQL("DROP TABLE IF EXISTS appdata_interviewquestions");
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_interviewquestions (id TEXT, subcode TEXT, html TEXT)");
}
android sqlite firebase-realtime-database
add a comment |
Okay so my app database is completely stored on firebase,
and my app updates its database every day.
What procedure i used to follow everytime during updating the data:
- Drop the current sqlite table
- Create the table again
- Fill in the data
This used to work perfectly, imagine a row is deleted so as i drop the whole table and rewrite the whole thing, the deleted row also get technically deleted from the local sqlite,But now there is a slight change in the table, there is a column, say "viewed" which stores if the particular row data is viewed or not, "true" or "false" (String)
Now if i drop the data while updating, it'll lose this column properties.
Then i thought of using UPDATE in sqlite and update the data of the columns of each row, but then there might be instances when a particular column is no more in the firebase, but if i do this, it will remain in my local database. (I mean that data is not edited but deleted). So how can i overcome this ?
Old Table :
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_videos (id TEXT, link TEXT, title TEXT, subcode TEXT)");
New Table :
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_videos (id TEXT, link TEXT, title TEXT, subcode TEXT, viewed TEXT)");
P.S. I am using firebase single time listener as i need to update data only once daily.
I used to run this function everytime i wanted to clear the database :
public void clearDB()
{
db.execSQL("DROP TABLE IF EXISTS subCodes");
db.execSQL("CREATE TABLE IF NOT EXISTS subCodes (id TEXT, dbName TEXT, subName TEXT, tagline TEXT, pref INTEGER, hasInterviewQuestions TEXT, hasVideos TEXT, hasCodes TEXT)");
db.execSQL("DROP TABLE IF EXISTS appdata_codes");
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_codes (id TEXT, question TEXT, code TEXT, tag TEXT, subcode TEXT, imglink TEXT, xlink TEXT)");
db.execSQL("DROP TABLE IF EXISTS appdata_videos");
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_videos (id TEXT, link TEXT, title TEXT, subcode TEXT)");
db.execSQL("DROP TABLE IF EXISTS appdata_interviewquestions");
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_interviewquestions (id TEXT, subcode TEXT, html TEXT)");
}
android sqlite firebase-realtime-database
when you drop and make a new table you will not have redundant data in the first place
– Pemba Tamang
Nov 28 '18 at 8:56
but now i am changing the table column.. i have a new column whose data should be contained
– Femn Dharamshi
Nov 28 '18 at 12:55
dont drop the table, update the table then delete whatever rows are not updated.
– Pemba Tamang
Nov 28 '18 at 13:00
how do i do that exactly
– Femn Dharamshi
Nov 28 '18 at 15:32
add a comment |
Okay so my app database is completely stored on firebase,
and my app updates its database every day.
What procedure i used to follow everytime during updating the data:
- Drop the current sqlite table
- Create the table again
- Fill in the data
This used to work perfectly, imagine a row is deleted so as i drop the whole table and rewrite the whole thing, the deleted row also get technically deleted from the local sqlite,But now there is a slight change in the table, there is a column, say "viewed" which stores if the particular row data is viewed or not, "true" or "false" (String)
Now if i drop the data while updating, it'll lose this column properties.
Then i thought of using UPDATE in sqlite and update the data of the columns of each row, but then there might be instances when a particular column is no more in the firebase, but if i do this, it will remain in my local database. (I mean that data is not edited but deleted). So how can i overcome this ?
Old Table :
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_videos (id TEXT, link TEXT, title TEXT, subcode TEXT)");
New Table :
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_videos (id TEXT, link TEXT, title TEXT, subcode TEXT, viewed TEXT)");
P.S. I am using firebase single time listener as i need to update data only once daily.
I used to run this function everytime i wanted to clear the database :
public void clearDB()
{
db.execSQL("DROP TABLE IF EXISTS subCodes");
db.execSQL("CREATE TABLE IF NOT EXISTS subCodes (id TEXT, dbName TEXT, subName TEXT, tagline TEXT, pref INTEGER, hasInterviewQuestions TEXT, hasVideos TEXT, hasCodes TEXT)");
db.execSQL("DROP TABLE IF EXISTS appdata_codes");
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_codes (id TEXT, question TEXT, code TEXT, tag TEXT, subcode TEXT, imglink TEXT, xlink TEXT)");
db.execSQL("DROP TABLE IF EXISTS appdata_videos");
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_videos (id TEXT, link TEXT, title TEXT, subcode TEXT)");
db.execSQL("DROP TABLE IF EXISTS appdata_interviewquestions");
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_interviewquestions (id TEXT, subcode TEXT, html TEXT)");
}
android sqlite firebase-realtime-database
Okay so my app database is completely stored on firebase,
and my app updates its database every day.
What procedure i used to follow everytime during updating the data:
- Drop the current sqlite table
- Create the table again
- Fill in the data
This used to work perfectly, imagine a row is deleted so as i drop the whole table and rewrite the whole thing, the deleted row also get technically deleted from the local sqlite,But now there is a slight change in the table, there is a column, say "viewed" which stores if the particular row data is viewed or not, "true" or "false" (String)
Now if i drop the data while updating, it'll lose this column properties.
Then i thought of using UPDATE in sqlite and update the data of the columns of each row, but then there might be instances when a particular column is no more in the firebase, but if i do this, it will remain in my local database. (I mean that data is not edited but deleted). So how can i overcome this ?
Old Table :
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_videos (id TEXT, link TEXT, title TEXT, subcode TEXT)");
New Table :
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_videos (id TEXT, link TEXT, title TEXT, subcode TEXT, viewed TEXT)");
P.S. I am using firebase single time listener as i need to update data only once daily.
I used to run this function everytime i wanted to clear the database :
public void clearDB()
{
db.execSQL("DROP TABLE IF EXISTS subCodes");
db.execSQL("CREATE TABLE IF NOT EXISTS subCodes (id TEXT, dbName TEXT, subName TEXT, tagline TEXT, pref INTEGER, hasInterviewQuestions TEXT, hasVideos TEXT, hasCodes TEXT)");
db.execSQL("DROP TABLE IF EXISTS appdata_codes");
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_codes (id TEXT, question TEXT, code TEXT, tag TEXT, subcode TEXT, imglink TEXT, xlink TEXT)");
db.execSQL("DROP TABLE IF EXISTS appdata_videos");
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_videos (id TEXT, link TEXT, title TEXT, subcode TEXT)");
db.execSQL("DROP TABLE IF EXISTS appdata_interviewquestions");
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_interviewquestions (id TEXT, subcode TEXT, html TEXT)");
}
android sqlite firebase-realtime-database
android sqlite firebase-realtime-database
edited Nov 27 '18 at 21:33
Femn Dharamshi
asked Nov 25 '18 at 21:06
Femn DharamshiFemn Dharamshi
50113
50113
when you drop and make a new table you will not have redundant data in the first place
– Pemba Tamang
Nov 28 '18 at 8:56
but now i am changing the table column.. i have a new column whose data should be contained
– Femn Dharamshi
Nov 28 '18 at 12:55
dont drop the table, update the table then delete whatever rows are not updated.
– Pemba Tamang
Nov 28 '18 at 13:00
how do i do that exactly
– Femn Dharamshi
Nov 28 '18 at 15:32
add a comment |
when you drop and make a new table you will not have redundant data in the first place
– Pemba Tamang
Nov 28 '18 at 8:56
but now i am changing the table column.. i have a new column whose data should be contained
– Femn Dharamshi
Nov 28 '18 at 12:55
dont drop the table, update the table then delete whatever rows are not updated.
– Pemba Tamang
Nov 28 '18 at 13:00
how do i do that exactly
– Femn Dharamshi
Nov 28 '18 at 15:32
when you drop and make a new table you will not have redundant data in the first place
– Pemba Tamang
Nov 28 '18 at 8:56
when you drop and make a new table you will not have redundant data in the first place
– Pemba Tamang
Nov 28 '18 at 8:56
but now i am changing the table column.. i have a new column whose data should be contained
– Femn Dharamshi
Nov 28 '18 at 12:55
but now i am changing the table column.. i have a new column whose data should be contained
– Femn Dharamshi
Nov 28 '18 at 12:55
dont drop the table, update the table then delete whatever rows are not updated.
– Pemba Tamang
Nov 28 '18 at 13:00
dont drop the table, update the table then delete whatever rows are not updated.
– Pemba Tamang
Nov 28 '18 at 13:00
how do i do that exactly
– Femn Dharamshi
Nov 28 '18 at 15:32
how do i do that exactly
– Femn Dharamshi
Nov 28 '18 at 15:32
add a comment |
1 Answer
1
active
oldest
votes
Hope this solution helps you,
step1: add a new column date to the new table
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_videos (id TEXT, link TEXT, title TEXT, subcode TEXT, viewed TEXT, date TEXT)");
step2:get ids from firebase and check if the ids exists in local database (loop through all the ids)
example:
if(isTheIdAvailableInLocalTable(idFromFirebase)){
//update the date column to todays date (dd-MM-yyyy)
}else{
//new entry so insert into local table with todays date (dd-MM-yyyy)
}
Step3:delete from local table where date not equal to tadays date.
This is an awesome solution. Thanks a lot. Now just help me with one thing. How to manage dates ? which class should i use to and how do i compare two dates
– Femn Dharamshi
Nov 29 '18 at 19:32
1
Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy"); String strDate= formatter.format(date);
– bk7
Nov 30 '18 at 4:58
1
compare the string "strDate.equals("30-11-2018")";
– bk7
Nov 30 '18 at 5:19
this looks ok but it is not advised to depend on dates in a database operation. If somehow your users device has the date changed...a glitch a reset a prank I don't know...this will fail. Use the ids instead of dates to be safe.Update the rows if the ids exist else delete them.
– Pemba Tamang
Dec 3 '18 at 5:30
2
let me break down a senario where this logic fails. Say you have two rows with dates03-12-18 => a
and03-12-18 =>b
so tomorrow new data comes in but the device date has not changed. Say itemb
has been deleted within the day and itema
is nowaa
. By your logica
will be updated toaa
butb
will not be deleted as step 3 will fail. So old data remains. Quite unlikely to happen but it is possible. Just a precaution otherwise your logic is ok @bk7. Sorry that I said use auuid
I meant use the item id thekey
instead of the date.
– Pemba Tamang
Dec 3 '18 at 9:16
|
show 5 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53471988%2ffirebase-database-storing-into-sqlite-database-with-some-properties-unchanged%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Hope this solution helps you,
step1: add a new column date to the new table
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_videos (id TEXT, link TEXT, title TEXT, subcode TEXT, viewed TEXT, date TEXT)");
step2:get ids from firebase and check if the ids exists in local database (loop through all the ids)
example:
if(isTheIdAvailableInLocalTable(idFromFirebase)){
//update the date column to todays date (dd-MM-yyyy)
}else{
//new entry so insert into local table with todays date (dd-MM-yyyy)
}
Step3:delete from local table where date not equal to tadays date.
This is an awesome solution. Thanks a lot. Now just help me with one thing. How to manage dates ? which class should i use to and how do i compare two dates
– Femn Dharamshi
Nov 29 '18 at 19:32
1
Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy"); String strDate= formatter.format(date);
– bk7
Nov 30 '18 at 4:58
1
compare the string "strDate.equals("30-11-2018")";
– bk7
Nov 30 '18 at 5:19
this looks ok but it is not advised to depend on dates in a database operation. If somehow your users device has the date changed...a glitch a reset a prank I don't know...this will fail. Use the ids instead of dates to be safe.Update the rows if the ids exist else delete them.
– Pemba Tamang
Dec 3 '18 at 5:30
2
let me break down a senario where this logic fails. Say you have two rows with dates03-12-18 => a
and03-12-18 =>b
so tomorrow new data comes in but the device date has not changed. Say itemb
has been deleted within the day and itema
is nowaa
. By your logica
will be updated toaa
butb
will not be deleted as step 3 will fail. So old data remains. Quite unlikely to happen but it is possible. Just a precaution otherwise your logic is ok @bk7. Sorry that I said use auuid
I meant use the item id thekey
instead of the date.
– Pemba Tamang
Dec 3 '18 at 9:16
|
show 5 more comments
Hope this solution helps you,
step1: add a new column date to the new table
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_videos (id TEXT, link TEXT, title TEXT, subcode TEXT, viewed TEXT, date TEXT)");
step2:get ids from firebase and check if the ids exists in local database (loop through all the ids)
example:
if(isTheIdAvailableInLocalTable(idFromFirebase)){
//update the date column to todays date (dd-MM-yyyy)
}else{
//new entry so insert into local table with todays date (dd-MM-yyyy)
}
Step3:delete from local table where date not equal to tadays date.
This is an awesome solution. Thanks a lot. Now just help me with one thing. How to manage dates ? which class should i use to and how do i compare two dates
– Femn Dharamshi
Nov 29 '18 at 19:32
1
Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy"); String strDate= formatter.format(date);
– bk7
Nov 30 '18 at 4:58
1
compare the string "strDate.equals("30-11-2018")";
– bk7
Nov 30 '18 at 5:19
this looks ok but it is not advised to depend on dates in a database operation. If somehow your users device has the date changed...a glitch a reset a prank I don't know...this will fail. Use the ids instead of dates to be safe.Update the rows if the ids exist else delete them.
– Pemba Tamang
Dec 3 '18 at 5:30
2
let me break down a senario where this logic fails. Say you have two rows with dates03-12-18 => a
and03-12-18 =>b
so tomorrow new data comes in but the device date has not changed. Say itemb
has been deleted within the day and itema
is nowaa
. By your logica
will be updated toaa
butb
will not be deleted as step 3 will fail. So old data remains. Quite unlikely to happen but it is possible. Just a precaution otherwise your logic is ok @bk7. Sorry that I said use auuid
I meant use the item id thekey
instead of the date.
– Pemba Tamang
Dec 3 '18 at 9:16
|
show 5 more comments
Hope this solution helps you,
step1: add a new column date to the new table
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_videos (id TEXT, link TEXT, title TEXT, subcode TEXT, viewed TEXT, date TEXT)");
step2:get ids from firebase and check if the ids exists in local database (loop through all the ids)
example:
if(isTheIdAvailableInLocalTable(idFromFirebase)){
//update the date column to todays date (dd-MM-yyyy)
}else{
//new entry so insert into local table with todays date (dd-MM-yyyy)
}
Step3:delete from local table where date not equal to tadays date.
Hope this solution helps you,
step1: add a new column date to the new table
db.execSQL("CREATE TABLE IF NOT EXISTS appdata_videos (id TEXT, link TEXT, title TEXT, subcode TEXT, viewed TEXT, date TEXT)");
step2:get ids from firebase and check if the ids exists in local database (loop through all the ids)
example:
if(isTheIdAvailableInLocalTable(idFromFirebase)){
//update the date column to todays date (dd-MM-yyyy)
}else{
//new entry so insert into local table with todays date (dd-MM-yyyy)
}
Step3:delete from local table where date not equal to tadays date.
answered Nov 29 '18 at 11:14
bk7bk7
3131310
3131310
This is an awesome solution. Thanks a lot. Now just help me with one thing. How to manage dates ? which class should i use to and how do i compare two dates
– Femn Dharamshi
Nov 29 '18 at 19:32
1
Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy"); String strDate= formatter.format(date);
– bk7
Nov 30 '18 at 4:58
1
compare the string "strDate.equals("30-11-2018")";
– bk7
Nov 30 '18 at 5:19
this looks ok but it is not advised to depend on dates in a database operation. If somehow your users device has the date changed...a glitch a reset a prank I don't know...this will fail. Use the ids instead of dates to be safe.Update the rows if the ids exist else delete them.
– Pemba Tamang
Dec 3 '18 at 5:30
2
let me break down a senario where this logic fails. Say you have two rows with dates03-12-18 => a
and03-12-18 =>b
so tomorrow new data comes in but the device date has not changed. Say itemb
has been deleted within the day and itema
is nowaa
. By your logica
will be updated toaa
butb
will not be deleted as step 3 will fail. So old data remains. Quite unlikely to happen but it is possible. Just a precaution otherwise your logic is ok @bk7. Sorry that I said use auuid
I meant use the item id thekey
instead of the date.
– Pemba Tamang
Dec 3 '18 at 9:16
|
show 5 more comments
This is an awesome solution. Thanks a lot. Now just help me with one thing. How to manage dates ? which class should i use to and how do i compare two dates
– Femn Dharamshi
Nov 29 '18 at 19:32
1
Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy"); String strDate= formatter.format(date);
– bk7
Nov 30 '18 at 4:58
1
compare the string "strDate.equals("30-11-2018")";
– bk7
Nov 30 '18 at 5:19
this looks ok but it is not advised to depend on dates in a database operation. If somehow your users device has the date changed...a glitch a reset a prank I don't know...this will fail. Use the ids instead of dates to be safe.Update the rows if the ids exist else delete them.
– Pemba Tamang
Dec 3 '18 at 5:30
2
let me break down a senario where this logic fails. Say you have two rows with dates03-12-18 => a
and03-12-18 =>b
so tomorrow new data comes in but the device date has not changed. Say itemb
has been deleted within the day and itema
is nowaa
. By your logica
will be updated toaa
butb
will not be deleted as step 3 will fail. So old data remains. Quite unlikely to happen but it is possible. Just a precaution otherwise your logic is ok @bk7. Sorry that I said use auuid
I meant use the item id thekey
instead of the date.
– Pemba Tamang
Dec 3 '18 at 9:16
This is an awesome solution. Thanks a lot. Now just help me with one thing. How to manage dates ? which class should i use to and how do i compare two dates
– Femn Dharamshi
Nov 29 '18 at 19:32
This is an awesome solution. Thanks a lot. Now just help me with one thing. How to manage dates ? which class should i use to and how do i compare two dates
– Femn Dharamshi
Nov 29 '18 at 19:32
1
1
Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy"); String strDate= formatter.format(date);
– bk7
Nov 30 '18 at 4:58
Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy"); String strDate= formatter.format(date);
– bk7
Nov 30 '18 at 4:58
1
1
compare the string "strDate.equals("30-11-2018")";
– bk7
Nov 30 '18 at 5:19
compare the string "strDate.equals("30-11-2018")";
– bk7
Nov 30 '18 at 5:19
this looks ok but it is not advised to depend on dates in a database operation. If somehow your users device has the date changed...a glitch a reset a prank I don't know...this will fail. Use the ids instead of dates to be safe.Update the rows if the ids exist else delete them.
– Pemba Tamang
Dec 3 '18 at 5:30
this looks ok but it is not advised to depend on dates in a database operation. If somehow your users device has the date changed...a glitch a reset a prank I don't know...this will fail. Use the ids instead of dates to be safe.Update the rows if the ids exist else delete them.
– Pemba Tamang
Dec 3 '18 at 5:30
2
2
let me break down a senario where this logic fails. Say you have two rows with dates
03-12-18 => a
and 03-12-18 =>b
so tomorrow new data comes in but the device date has not changed. Say item b
has been deleted within the day and item a
is now aa
. By your logic a
will be updated to aa
but b
will not be deleted as step 3 will fail. So old data remains. Quite unlikely to happen but it is possible. Just a precaution otherwise your logic is ok @bk7. Sorry that I said use a uuid
I meant use the item id the key
instead of the date.– Pemba Tamang
Dec 3 '18 at 9:16
let me break down a senario where this logic fails. Say you have two rows with dates
03-12-18 => a
and 03-12-18 =>b
so tomorrow new data comes in but the device date has not changed. Say item b
has been deleted within the day and item a
is now aa
. By your logic a
will be updated to aa
but b
will not be deleted as step 3 will fail. So old data remains. Quite unlikely to happen but it is possible. Just a precaution otherwise your logic is ok @bk7. Sorry that I said use a uuid
I meant use the item id the key
instead of the date.– Pemba Tamang
Dec 3 '18 at 9:16
|
show 5 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53471988%2ffirebase-database-storing-into-sqlite-database-with-some-properties-unchanged%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
when you drop and make a new table you will not have redundant data in the first place
– Pemba Tamang
Nov 28 '18 at 8:56
but now i am changing the table column.. i have a new column whose data should be contained
– Femn Dharamshi
Nov 28 '18 at 12:55
dont drop the table, update the table then delete whatever rows are not updated.
– Pemba Tamang
Nov 28 '18 at 13:00
how do i do that exactly
– Femn Dharamshi
Nov 28 '18 at 15:32