I'll start by saying I am not a DBA and I didn't get to do heavy database development so far (so I hope I'm not asking something obvious).
The Challenge:
- I have a dictionary application with pre-defined values.
- New values may be added via online updates.
- Users are not allowed to modify these application-values, but they may add/delete values of their own.
- The database (sqlite3) will contain a small amount of values (~2K-3K).
- The database schema is exactly the same for both user and application values.
Possible solutions:
One way to go about it would be to create two different tables having the same schema, and JOIN the data from both tables when querying the database.
A different approach would be to have a single table in which application-values will start at ID=0, and user-values will start at ID=100000 (for example). Online updates will merge new values below ID=100000 such that user values will remain i开发者_如何学运维ntact.
I prefer the second solution - it'll avoid JOINs during runtime and the queries will remain simple.
However, an update to the application-values in the first solution would require me to just replace the application table with the new one.Please let me know what you think:
- Which solution is better?
- What are the pros/cons that I'm missing?
- Is there an even-better third solution?
Why not just a column 'type' to your table and fill it with user/application?
Personaly I hate meaningfull ID's....
精彩评论