this might be a simple question but when creating a database can you instead assign what the id will be instead of having it auto increment?
what i want to do is make a database with people where i can do a query using their phone number to get more information about that person in other columns.
can that be done or can i do the same thing creating the database with an auto incrementing id?
Android uses sqlite databases; they come with a “hidden” id column that autoincrements and which gets linked to any INTEGER column you define as a PRIMARY KEY.
So you can’t get rid of the additional auto-incrementing column (it’s used internally by sqlite). But nothing keeps you from just defining your own PRIMARY KEY column that is NOT of type INTEGER. If you do that, the hidden _id column stays hidden.
So, you can do:
and use phone_number as the primary key in this table without ever worrying about the hidden _id column.
However, I also suggest (as Farray does) that you use an integer ID. The phone number is a very bad primary key, as people’s phone numbers may change and this means you will have to update lots of tables when one does. Also, if you don’t store international phone numbers, your phone numbers may not be unique and therefore fail as primary keys.