I'm dealing with a lot of similar Event classes that need to be stored in a DB. They all inherit from AbstractEvent and implement the interface IEvent. The main difference lies in their properties:
RainStartsEvent
TimeRainStarted: Time
LitresOfRainPerSquareMeter: Float
RainTemperature: Integer
SunUpEvent
TimeSunUp: Time
PersonWhoSawItFirst: Integer
Brightness: Float
SongOfTheDay: String
SomeOtherEvent
UniquePropery1: someType
StandardProperty: someType
and so on. There will be dozens or even hundreds of Events and they potentially have nothing in common except what they inherit form AbstactEvent and implement from IEvent.
Now I need to store those objects in the database. I thought about Single-Table-Inheritance or Table-Per-Hierarchy-Inheritance but it doesn't make sense because of the large and ever increasing number of Events. I would end up with a table that exceeds 255 fields.
The other idea I had is to store all Events in a single table and all their properties in a different table, one property per row with a foreign key to the Events table. However, that would mean I have to store them all as string and do a lot of (de)serializing, i.e. this may not perform very well in a system with a large number of Events.
Do I need to use the .NET Object Serialization to make this perform better? Would that help?
What else is possible? There must be a more standard solution for this problem, some sort of best practice or design pattern. Any ideas?
Aucun commentaire:
Enregistrer un commentaire