In my app, I have a part that deletes a record in my SQL database, but it also deletes records with the same value.
Example:
Names
Sam
John
Sam
Neil
If I delete one of the records containing the value "Neil", both of the records containing the value Neil are deleted.
How could I stop this from happening?
I thought about having a second field in my table and giving each field an ID, but this would cause bigger problems later.
The problem I see appearing is that say I have 4 records in my database, each with an ID from 1-4:
1. This
2. Is
3. My
4. Example
And I delete record 3, then the records will be 1,2,4 which will cause me more trouble if I decide to do something such as restrict the amount of records that can be entered.
The advantage of the ID is that it's UNIQUE !
In SQLite you can get the number of records.
In my DB applications when I read a database and show it in a table I define in parralel a List with the ID indexes to have a relationship between the rows and the IDs. This is valid for the whole database and also if it's filtered.