Consider a situation where the schema of a database table may change, that is, the fields, number of fields, and types of those fields may vary based on, say a client ID.
Take, for example a Users
table. Typically we would represent this in a horizontal table with the following fields:
- FirstName
- LastName
- Age
However, as I mentioned, each client may have different requirements.
I was thinking that to represent a multi-schema approach to Users
in a relational database like SQL Server, this would be done with two tables:
- UsersFieldNames - {FieldNameId, ClientId, FieldName, FieldType}
- UsersValues - {UserValueId, FieldNameId, FieldValue}
To retrieve the data (using EntityFramework DB First), I'm thinking pivot table, and the use of something like LINQ Extentions - Pivot Extensions may be useful.
I would like to know of any other approaches that would satisfy this requirement.
I'm asking this question for my own curiosity, as I recall similar conversations coming up in the past, and in relation to this question posed.
Thanks.