Link to home
Start Free TrialLog in
Avatar of Andy Green
Andy GreenFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How best to represent and model data

Hi

Using EF Core I'm struggling how to model data. I'm also new to EF so bear with me.

We are storing personnel data thats changed, so some fields will be strings like name, some will be objects (Value Objects) like addresses, boolean flag values and dates. We need to try to keep the correct data type for type saftey, only a very limited subset of the data will be stored.

As you can see we have every kind of data to persist.

I'm struggling how to even model this using a data first approach let alone EF.

I'm kinda leaning towards saving everything as strings and use code inthe domain layer to check / maintain type safety, but value objects like address still present a problem, do I have a single row for all proprties or a separate row with a key and 1 property per row?

Not all data will be relavent or persisted per person, for example 1 person might update their name, another their address and another their marketing preferences, these need to be stored temporarily until approved when the master record will be updated.

Does anyone get what I'm after and any pointers on how to get going.

Andy
Avatar of Andy Green
Andy Green
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

My options are I think, a model with all the updatable fields, most of which will contain 1 updated field and the rest null, a model for each updatable field type (object, bool, string) or a model with a string, but lose type safety. Any thoughts?
Andy
Avatar of ste5an
I'm kinda leaning towards saving everything as strings and use code in the domain layer to check / maintain type safety,
Then you definitively have no type safety. Cause type safety implies to use the most strict available datatypes matching the domains.
Further more storing everything as string and doing your own type checks means it is no longer a database first approach. Cause it prevents data manipulation and sometimes even data retrieval on database level for e.g. reporting without duplicating your own domain system in the database.
ASKER CERTIFIED SOLUTION
Avatar of Andy Green
Andy Green
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial