views:

134

answers:

1

I'm going to be working on an application that allows our client to define fields that will be shown to users in sort of a feedback/survey environment. For example, a pizzeria might have a field asking for your favorite topping, a bar might have your favorite brand of beer.

The system needs to be able to handle letting our customers create and modify these fields, since they are dependent on the specific customer and probably will not be duplicated. It would be ideal if there was some way to present suggestions to the customer based on similar customer's fields; for example if we have a second pizzeria sign up, on their admin page to define fields it might say that similar businesses chose to ask the following questions, and present a list of "sample" values.

Would this be a good candidate for the Entity-Attribute-Value (EAV) model for this table? A traditional relational model wouldn't work because it would involve lots of fields called "user1" and the like, which is of course highly unwieldy for anything.

+1  A: 

No, the system you describe does not require an EAV, although what you see below may appear to have some common elements with EAV models:

CLIENT (clientId, clientName)

SURVEY (surveyId, clientId)

RESPONDENT (respondentId, surveyId, respondentName, respondentEmail)

QUESTION (questionId, surveyId, questionText) e.g. "favorite topping"

OPTION (questionId, responseText) e.g. "anchovies", "pepperoni"

RESPONSE (questionId, respondentId, responseText)

A CLIENT can create many SURVEYs, each of which can have many QUESTIONs, some with suggested OPTIONs. A RESPONDENT responds to a SURVEY, and their answers are each recorded as a RESPONSE. RESPONSE.responseText may or may not match a given OPTION.responseText, depending on whether they picked an option or typed their own response.

This is just an example, there are many variations on this model that you'll probably need to make to suit your specific requirements.

Jeffrey Kemp