Create new Local ID or Retreive 1 from Online DB ?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Create new Local ID or Retreive 1 from Online DB ?
HI,
i would like to know what steps you do use for your production App at the time of creating a new (unic) ID in an Online DB account.
I figure out it could only use 1 or the other 2 ways below, right ?
1) On device. Pressing "Create new user account" buttton,
- 1rst connect to the onilne DB...
- look for the last free id number..
- Retreives that number to the device Sqlite DB.
- Add new users infos (name,etc) to the new account localy.
- Update the online New "empty account" id with device local complete info.
- Send message to device to confirm : "new user account created"
***
..or
2) "Create a new user account localy with(or)without an Id number (? )
- Connect to the Online DB,
- Add the new account to the end of the Account-table.
- retreive the Final-real-id number.
- update the Device local sqlite DB with the Online ID number.
- confirm to user : "new user account created"
***
Is one way safer/better than the other ?
- I want to avoid : Useless Id created with empty accounts info.
- Inconsistent Id numbers between Online Ids and Local Users.
- Any other inconsistency in case of internet interruptions or user canceling Ops., etc..
Tkx
i would like to know what steps you do use for your production App at the time of creating a new (unic) ID in an Online DB account.
I figure out it could only use 1 or the other 2 ways below, right ?
1) On device. Pressing "Create new user account" buttton,
- 1rst connect to the onilne DB...
- look for the last free id number..
- Retreives that number to the device Sqlite DB.
- Add new users infos (name,etc) to the new account localy.
- Update the online New "empty account" id with device local complete info.
- Send message to device to confirm : "new user account created"
***
..or
2) "Create a new user account localy with(or)without an Id number (? )
- Connect to the Online DB,
- Add the new account to the end of the Account-table.
- retreive the Final-real-id number.
- update the Device local sqlite DB with the Online ID number.
- confirm to user : "new user account created"
***
Is one way safer/better than the other ?
- I want to avoid : Useless Id created with empty accounts info.
- Inconsistent Id numbers between Online Ids and Local Users.
- Any other inconsistency in case of internet interruptions or user canceling Ops., etc..
Tkx
Re: Create new Local ID or Retreive 1 from Online DB ?
Make a distinction between an internal and en external ID. The internal ID is for the database and links records of different tables. The external ID is for you, e.g. a client number. The client number is stored in only one table in the database, while the internal ID is stored wherever applicable. You might want to write a trigger script that created new records with the same unique internal ID number in every table.
- set up the database such as to create new unique ID numbers automatically
- insert new record
- retrieve data by client ID (as in above example)
- use internal ID number to retrieve data from other tables
If you happen to make a mistake, you might enter a duplicate client number while the new records are still correctly linked by the internal ID number.
Don't make your database more complicated than really necessary!
- set up the database such as to create new unique ID numbers automatically
- insert new record
- retrieve data by client ID (as in above example)
- use internal ID number to retrieve data from other tables
If you happen to make a mistake, you might enter a duplicate client number while the new records are still correctly linked by the internal ID number.
Don't make your database more complicated than really necessary!
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Create new Local ID or Retreive 1 from Online DB ?
Thanks Mark, So the internal number can use the Auto_increment Field property, while the External would need to be coded to emulate such unic number ?
Re: Create new Local ID or Retreive 1 from Online DB ?
Why "emulate"? That concept doesn't make sense here. Internal and external ID's are just different things with different purposes. As I said, don't make it more complex than necessary.
Mark
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Create new Local ID or Retreive 1 from Online DB ?
By "Coding to emulate" here , I mean that there must be a script used at some time to "fabricate" a client ID that is a litle more smarter than just just starting with :The external ID is for you, e.g. a client number. The client number is stored in only one table in the database,
- 1rst Client added to the empty Table will inherit Id number 1.
- 2nd Client in the Table will inherit Id number 2...
Re: Create new Local ID or Retreive 1 from Online DB ?
Well, no, why would it have to be smarter than that? The point is just that sometimes internal and external ID's aren't the same, so if you decide to use an external ID like a customer number, you often may want to consider this a field just like any other and use the internal, automatically generated, ID to make queries involving multiple tables. That's really all there is to it and there is no such thing as "emulate" or "fabricate".
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Create new Local ID or Retreive 1 from Online DB ?
..sql injection, using too easy guessable IDs !Well, no, why would it have to be smarter than that?
Re: Create new Local ID or Retreive 1 from Online DB ?
Usually ID's are easy to guess and protection against SQL injection isn't done by complicated ID numbers.
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Create new Local ID or Retreive 1 from Online DB ?
What Mark said. If someone can break/hack your database because of guessing an id they already have more access and control than they should. I'm not sure I understand your exact needs though.
Re: Create new Local ID or Retreive 1 from Online DB ?
...guesssing values is part of a brute force breaking process, By having (guessed) a single user ID of your table it may be enuff for sneakers to get this complete user info alone - but not all others users from the same table - while if youd use a simple sequencial numbers, this would just makes breaking into all other users accounts much more easy for them.
Re: Create new Local ID or Retreive 1 from Online DB ?
Whatever. If you think you know best, then why did you ask your question in the first place.
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Create new Local ID or Retreive 1 from Online DB ?
Take it easy Mark
Actually you taught me there were two types of Ids, internal and external - which I didnt know before you mentioned it.
..which in turn led me to search how should I enforced them..that´s all. I´m not saying keeping things simple is bad.
i believe it all depend of the time and level of "Paranoia´s details" one wants to build its app with when it comes to the security side..and I´m probably one with a good level of paranoia !
no offence...
Actually you taught me there were two types of Ids, internal and external - which I didnt know before you mentioned it.
..which in turn led me to search how should I enforced them..that´s all. I´m not saying keeping things simple is bad.
i believe it all depend of the time and level of "Paranoia´s details" one wants to build its app with when it comes to the security side..and I´m probably one with a good level of paranoia !
no offence...
Re: Create new Local ID or Retreive 1 from Online DB ?
No, you're not at a good level of paranoia. You're the type who would kill his app for security's sake. First learn something about threats and security and then decide which level of security you need. Leave out terms like paranoia. That's not a term that should be used in software engineering and even less so in science.
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode