开发者

Design extended properties for entity with complex data inside

I have design question. I have entity such as "Person". Person has properties such as: FirstName, LastName, Gender, BirthDate, .... End user when create a person in application may be need to define another property that is not defined in database table schema (or class person). for example开发者_运维技巧: end user nead to define "property1" that its a string property. or nead define "proerty2" that its a image, or need define "property3" that its complex type.

please separate your design solution in tow level: 1-database table design

2-class design

thechnology: .NET Framework, SQL Server, WCF (All entity must be serializ over wire, special complec data in extended properties)

thank u.


Here's a starter for you, although more information would be helpful, such as what platform you're working in.

You could try a value/key pair approach, although you'll need to extend this futher so that you can assign different values to different entity instances.

In your database you might have a table with:

  • Unique row id
  • Entity id
  • property key
  • property value

If you're going to reuse this for other entity types you'll need an additional column to keep those types seperated.

If you're working in .Net you can design interfaces that decribe certain properties you want to work with at the API level.

You might access the properties in the database via a class which serves as a "property utility", this would be used internally by the entity, or the factory that creates them.


This looks like Entity-Attribute-Value model. Look for implementations for your technology stack.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜