I altered a requirement of the project, Originally I decided that I would only have one implementation of each time e.g only one category of type book. I was thinking that I would rather have many instances of each type. Say I wanted to have favourites book list and a 2nd books I hate list. This would have been impossible with my first implementation.
I have altered the DB schema accordingly. There is now a table for each type that will store each instance as a row, the instance data is serialized into Json. I have not normalizing the data further and thus have avoided second and third tables for each category.
Each type needs its own DB class which cannot be generic as specific SQL queries are needed for each type. I have implement and interface ICategory.
Each Type will implement this interface and the IErrorLog which contains a simple method to log each exception in a textfile.
Each Type is able to save an instance of itself into a SQLite table. Now all we need is a generic collection to interact with.
This generic collection when created gather all items in the DB for that type and de-serialize them into a collection. Any items added removed or updated will be altered in the DB table as well.
The main purpose of this collection is to provide and abstraction to the DB and allow all instances to be serialized and sent to the client. A data-table could be used in this collections place.
What’s Next?
- Test, must write a test for these interfaces and magic data for each type.
- Implement the interfaces IErrorLog and ICategory in all category types, 8 in all