I'm fairly new to the database queries and such and right away I find my self with a complex situation.
My DB table contains 3 columns:
_id | stringValue | timeStamp
I have 3 constraints;
- Max rows allowed equals 100.
- If table is full the oldest item will be removed.
- If a new item to be added matches the stringValue than only the timestamp will be updated.
I'm currently making 3 queries:
- Check if item already exists if it does just update it. If it doesn't just add it.
- If item did not exist check how many items are on the table
- If over 100 items remove the oldest
I'm thinking there might be a one query I can do to achieve all this... Any tips or ideas would be appreciated!