views:

36

answers:

1

Hi, I am working on a billing system for service provider and I have to implement something named Customizable preferences schema. Main feature should be to allow administrator to define which fields are mandatory in various situations. E.g. if customer only registers on site, he has to enter first name, last name and e-mail address. If he orders something that is billable, than he should enter some basic address data, but if he wants something specific, he should enter billing and shipping address. I want to allow administrator to define which fields are mandatory for address for each product (or category) and which addresses (billing, shipping, main, etc) are mandatory. If more than one address is needed for one product/service than all of them has the same list of required fields. One important thing is that definition of additional fields should be allowed. Rules for choosing address schema will be based on product and/or country.

My question is what should be appropriate model for this problem. I suppose that customer object should have list of addresses. Every address should have it's name (Billing, Main, Shipping) and reference to its values. On database side, my idea is to have one table for addresses with standard attributes as columns and to have one EAV table for custom attributes (defined by administrator). I have considered Class Table Inheritance but it is not appropriate here because I don't have final set of attributes for addresses. Second option was to use XML column for storing custom attributes, but I haven't worked with that data type and I am not sure about performances. I know that EAV is not standard relational design but it look OK here. But, like I said, I am not 100% sure about any of this solutions and would like to hear some other ideas.

Thanks in advance.

+1  A: 

Take a look at this discussion.

Damir Sudarevic