2

Our Sitecore project needs to store some custom data (results from a user poll). Is there some sort of a built-in functionality for storing that data on Sitecore sites?

The obvious solution is to create a separate custom database, but I'd like to know if Sitecore offers a better approach.

2 Answers 2

4

Choosing a Storage Location

If you have a scaled instance of Sitecore or if you want your instance to be extensible and scalable, then you need to avoid storing data in the master database, as CD instances wouldn't have access to it. The web database is also not an option, as you would lose the data on publish.

You basically have three options:

  1. Add another Sitecore database for storing your form data. This would be a database that both the CM and CD connect to, but not a publishing target.
  2. Add an external SQL or NoSQL database that you create yourself.
  3. Write custom logic to store your form data in MongoDB, which both the CM and CD connect to.

In a situation like the one you are describing, I would typically advise you to go with option 1, and use an extra Sitecore database. This will not violate your Sitecore license in any way, and will likely be the lowest effort solution. This is largely due to the amount of known structure that you have with your data, since it the results from a user poll.

Have a look at this answer to a different question on how to store user-generated content (UGC) in a Sitecore solution. In the answer, I break down the various factors that go into choosing where the data should be stored and why.

Storage Structure

Assuming you went with option 1, above, (if you didn't then that's fine - you can just translate this structure into SQL or NoSQL) then I suggest that you use the structure described below for your data.

First, you will need to create an item template to represent the user-poll that it will contain the results of. Next, you will create another item template to represent the data record from a user form submission. My recommendation would be to then have a third template to represent a form field. Based on the fields that are filled out by the user, you could programmatically add all of the fields from the submission to Sitecore, and not have to worry about carrying over changes to the form that are made later.

I recommend that you use a bucketing strategy for the records, as this will help you avoid slow-downs when querying, if your polls are to be filled out by a large number of users. You can use content search to access the results of the poll via query, and create a custom reporting tool that displays them.

1
0

You can create a sitecore item structure to store the poll results. In this case you would need a Template to store a poll item and a Folder Template that can insert those items.

You'll end up with something like: Data

  • Polls (folder)
    • Poll Item
    • Poll Item

You could also make the Polls folder into a bucket if there will be lots of items.

5
  • This wouldn't allow me to store individual votes easily though, right? Because each vote would then be an Item, which is not feasible.
    – user1475
    Commented Feb 28, 2017 at 14:30
  • I think we need to know more about your needs to properly answer that. Can you please update the question with more information about the structure of the data that you need to store. Commented Feb 28, 2017 at 14:32
  • As Mark says, if you have a scaled environment then this won't work. If not you can always store data in Web and disable publishing on those containers to prevent overwriting them. Commented Feb 28, 2017 at 14:35
  • It is a scaled environment. The data structure will have a single row (with let's say 5 columns) for each vote.
    – user1475
    Commented Feb 28, 2017 at 14:39
  • OK, then in order to do it with Sitecore you'll want option #1 above. Stored as sitecore items, your 'row' is the Item itself and the 'columns' are fields within that item. Commented Feb 28, 2017 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.