1

I want to create a membership based site in Umbraco 7, following the umbraco.tv videos and reading through the docs have got me quite far.

My members will have custom properties, firstname, lastname, favourite colours, hats owned etc. I have been adding each of these as custom properties and then assigning them to the tab I want. This works fine and I can then access them from code using:

Members.GetCurrentMember().GetProperty("lastname").Value.ToString();

When I looked in my database I noticed that each of these custom properties is a row in the cmsPropertyData table, linked to the cmsMember table by the nodeId column. Is there a way I can set all of this information to store in it's own table?

Ideally, I want each Member to have a one to many relationship with favourite colours, as well as one to many relationships with other tables; each member might have 100 hats for example. What is the best way for me to set this up? Shall I create custom tables in my Umbraco database for HatsOwned and FavouriteColours, then assign each Member a unique ID so I can set my foreign keys up correctly? That way I would only need to store the Members Unique Id in the cmsPropertyTable. Is there a better way to let Umbraco deal with it? Would I have difficulty retrieving Members using either the Umbraco orm, or EF?

Any help or pointers greatly appreciated!

Jim
  • 737
  • 3
  • 12
  • 27

1 Answers1

1

I would store all data in the PROFILE of the member, in the umbraco membership. E.g. timezone, hair color, ... This makes sense for other developers to find back the data.

For all other data, you have a few options:

Relationships

If you want to link nodes to members, or nodes to nodes, or... Relations link 2 umbraco entities and can be one way or two way. If you have a color node, you can link all members to this node. Just create a "favoriteColor" relationship on the developer section, linking up nodes to members. Do some programming and you are done. Don't forget that a relation is a database record linking 2 umbraco entities. So think of some caching if you use this in your front end to take off some database load. Read more on the Relationship Api in the umbraco documentation.

Content

It's pretty easy to create new nodes using code to store e.g. comments on an article. Because you are republishing the xml cache every time you create (and publish) a node, don't use content nodes for stroring your data if you have a lot of updates.

External data

It is perfectly legit to store data outside of umbraco. Just create your own tables (or content to any service you created). You could use every ORM you want to, but I would recommend PetaPoco. The reason is obvious. Umbraco uses it also. And it will make you a better Umbraco developer. There is a detailed post on stackoverflow on how to work with external data in umbraco.

Community
  • 1
  • 1
dampee
  • 3,392
  • 1
  • 21
  • 37
  • Thanks very much for your answer and links, I've read through them both and have learned quite a bit, but I still don't fully understand how best to solve my issue. I want to store my favourite colours in a table which is outside of Umbraco (but can be in the same database). You say that's fine to do, so is there a way I can set up a foreign key relationship between cmsMember and my custom table? Can I just do it in SSMS, using the cmsMember nodeId as the Primary Key? This seems to work fine, but I just don't know if it's correct. Thanks for you help! – Jim Dec 29 '14 at 11:40
  • Yes, Use SSMS to create a foreign key. – dampee Dec 29 '14 at 17:04
  • 1
    Above all worked fine. Decided to use a custom Membership Provider in the end though as I ideally want to keep my Umbraco database separate from the main one. Thanks for your help! – Jim Jan 18 '15 at 11:51