Each contact in the address book, has a unique Id,
1) will this Id ever change? if so when does it change? ie a user deletes a contact, will the other contact id change? how do we make sure of this? will not change now or in the future.
EDIT: would like to uniquely identify a contact, which id should I use as a reference?
The documentation says:
The recommended way to keep a
long-term reference to a particular
record is to store the first and last
name, or a hash of the first and last
name, in addition to the identifier.
When you look up a record by ID,
compare the record’s name to your
stored name. If they don’t match, use
the stored name to find the record,
and store the new ID for the record.
Have one unique field like contact or address and compare the record's name with that field as well as id.
Related
We have a table that contains a user's email address, their first name and last name and some date columns. The standard search works great for those.
I would like to provide a way of the user being searchable by their user id which is a GUID. The user id is not a visible piece of data. This search would really only be used by admins
I know I could use the data-search attribute on the user name column e.g.
data-search="43b30438-e3c8-4e27-8b31-5fcc52e53a3b me#test.com"
However that makes that row and any other row findable with just the number "43" as that GUID starts with 43 or "52" because it has a 5 followed by an 2. That is clearly not what I want. How do I make the users searchable by their GUID as well as their username but in the case of the GUID only when it is the whole GUID being searched for?
Thanks
Sql question.
I have a customer table with:
User id, name, email, phone
The customer can update their name, email and phone at anytime on an app.
How can I find out which user id had changes in name, email or phone number on a particular date?
Since your table doesn't store the date that they made the changes, you can't.
If you add a column with a datetime type (or whatever your specific database product provides) - you could call it LastModified or something like that - then the solution becomes trivial.
I'd give you a specific example, but because you didn't tell us what database engine you use, I can't guarantee to get the syntax right.
This is an issue with RDBMSes, you cannot as they generally store say a "photograph" of your data in time not a "film" of how it got there.
Based on the RDBMS you use, you can introduce an updated_at field which will hold when the last change happened to that row either from the "UPDATE" statement (say 'UPDATE phone=000, updated_at=now() WHERE user_id=999') or set it up to autoupdate see: create column for auto-date in postgresql
I want to check if the message what I got comes form the particular user and I want to check him by his Name or ID, because for some users I don't know the Id yet. Is there a good way to do it?
I have MS ACCESS 2010 database that I made for some of my co-workers. The purpose of the database is to gather manual information in more automated way about some employees (instead of emailing files or having to rely on buggy excel sharing features).
I managed to make sure that each user see only their own data using query as a mean of interfacing with user and checking windows api to get user name.
Now I have a specific problem that I don't know how to solve:
Table contains of 3 columns that user have to enter manually:
ID
Name
Location
ID is not ID of this table, its an ID from totally different system that I can not interface with so it have to be manually entered along with name as I need it later. ID is unique for each employee.
Now I made sure that user can not enter unique combination of those three columns twice using constrains (the same name/id can be used for different locations), but what is possible is that user enter the same ID with different name (not good), or the same name with different ID (possible as employees may have the same name).
Is there a way to check upon entering of data if a given ID exists with different name then the one entered by the user?
Example:
ID NAME LOCATION
123 Martin Warszawa - OK
123 Martin Kraków - OK (the same person assigned to his second location)
124 Martin Kraków - OK (same name as another guy from Kraków, but two different persons)
123 Paul Wrocław - NOT OK (ID points to Martin, so it should not be entered as Paul)
123 Martin Warszawa - NOT OK (duplicated first row - blocked with constrains)
Can this even be accomplished?
What I would want to retain is the ability to enter values by users in the query window and this as far as I know will be compromised if I change this into One:Many table relationship.
I assume that macro/sql procedure could be used to accomplish that and block insert attempt but I don't know how to accomplish it
Normalize your database. You have users identified by an ID (primary key bold):
users (id, name)
and their locations:
user_locations (user_id, location)
So there can be no longer be duplicate user entries and there can be no duplicate locations. If you want to add something, use INSERT. If that fails, it means the entry is already there. If you want to update something, use UPDATE. If you want to insert or update depending, try INSERT first; if this fails UPDATE. (You can search for upsert and MS-Access, and you will find how this is done).
I'm making a game involving the user's contacts, but need a way to uniquely identify each contact. This is because the user can easily change the name, phone number, or other property of a given contact. Is there a way to do this?
You can use ABRecordGetRecordID() to get the unique ID of a record. It returns an ABRecordID which is a typedef for int32_t.
ABRecordGetRecordID() is the API that you can use. However, apple documentation does states some noteworthy points about the ABRecordID returned by this API.
Every record in the Address Book database has a unique record identifier. This identifier always refers to the same record, unless that record is deleted or the data is reset. Record identifiers can be safely passed between threads. They are not guaranteed to remain the same across devices.
The suggested method as per apple guidelines is
The recommended way to keep a long-term reference to a particular record is to store the first and last name, or a hash of the first and last name, in addition to the identifier. When you look up a record by ID, compare the record’s name to your stored name. If they don’t match, use the stored name to find the record, and store the new ID for the record.
In my app, I am also checking for creation date of the contact since the name against the ABRecordID could have been changed by the user. Creation date of a contact DOES NOT change upon device reset.
Though I have pasted most of the content here, its always advised to read the documentation