﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Joseph Healy commented on Multi Tenancy - Extensible Data Model</title><description>From http://www.fsinsider.com/developers/Pages/default.aspx
  
  
 ---------------------------------------------------------------------------
  
  
"As Extensible As It Gets"
  
  
The success of the Flight Simulator franchise is due in large part to the efforts of our third-party development community. Those efforts are made possible by our commitment to "extensibility."
  
  
The main idea behind this concept is to provide customers with the power to customize their experiences. Over our 25-year history the names and faces on our team have changed, but our dedication to this concept has remained.
  
  
---------------------------------------------------------------------------
  
  
I'm not from that world, but it makes sense to me that extensibility would be a key element of keeping games interesting to gamers and game platforms interesting to game developers and third parites...
  
  
  
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment35</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment35</guid><pubDate>Sun, 17 Aug 2008 09:35:17 GMT</pubDate></item><item><title>Ayende Rahien commented on Multi Tenancy - Extensible Data Model</title><description>Why do you think they need extensible data support in those games?
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment34</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment34</guid><pubDate>Sun, 17 Aug 2008 00:44:38 GMT</pubDate></item><item><title>Joseph Healy commented on Multi Tenancy - Extensible Data Model</title><description>Would be interesting to hear the thoughts of someone in the MS Flight Simulator / Game crews on the subject as I suspect they deal with this on a fairly regular basis. Anyone have contacts might want to consider asking them to chime in...
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment33</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment33</guid><pubDate>Sun, 17 Aug 2008 00:41:22 GMT</pubDate></item><item><title>Joseph Healy commented on Multi Tenancy - Extensible Data Model</title><description>I don't know about 'great' as it's not an approach devoid of complexity itself, but there are enhancements to SQL Server's XML capabilities - the summary from the white paper on the enhancements: 
  
  
Microsoft® SQL Server™ 2008 builds on the extensive support for XML by extending support for XML schema validation and XQuery, and by enhancing the xml data type
  
  
-XML Schema Validation Enhancements
  
-Lax Validation Support
  
-Full xs:datetime Support
  
-Union and List Types
  
-XQuery Enhancements
  
-XML DML Enhancements 
  
  
http://www.microsoft.com/sqlserver/2008/en/us/wp-sql-2008-whats-new-xml.aspx
  
  
I would say these enhancements make taking this approach a bit more reasonable proposition - if you're up for an XML-centric soloution to begin with. That said, I'm certainly of the mind data extensibility is a complex problem space with no simple solutions. All-in-all it almost seems more a matter of shuffling the complexity around to a form which is comfortable for any given developer rather than finding a solution which actually reduces it.
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment32</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment32</guid><pubDate>Sat, 16 Aug 2008 22:27:25 GMT</pubDate></item><item><title>Ayende Rahien commented on Multi Tenancy - Extensible Data Model</title><description>Joseph,
  
I am not keeping up, what is great with XML in 2008?
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment31</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment31</guid><pubDate>Sat, 16 Aug 2008 21:03:47 GMT</pubDate></item><item><title>Joseph Healy commented on Multi Tenancy - Extensible Data Model</title><description>Any comment on whether new SQL Server 2008 XML features changes anyone's mind relative to using XML for data extensibility? I still see it as reasonable approach compared to the complexity inherent in most of the alternatives.
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment30</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment30</guid><pubDate>Sat, 16 Aug 2008 20:58:50 GMT</pubDate></item><item><title>Paul Cowan commented on Multi Tenancy - Extensible Data Model</title><description>For custom fields, validation is also a consideration.
  
  
I render my custom fields onto the web page dependant on their defintion.
  
  
The best I have come up with for validation is to allow a regular expression to be associated with the field.
  
  
Actually changing the ddl sounds like a bad plan.
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment29</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment29</guid><pubDate>Sat, 09 Aug 2008 20:47:06 GMT</pubDate></item><item><title>Dan Malcolm commented on Multi Tenancy - Extensible Data Model</title><description>I've used the "Key Value" option for a multi tenant e-commerce system (separate databases btw...).  We have a CustomAttributeDefinition class which contains metadata about properties that can be set up against a particular type of entity. CustomAttributes are the actual realisation of the property for an entity. 
  
  
I would emphasise the importance of having a rich metadata layer for defining behaviour, rules and constraints for these custom properties.
  
  
CustomAttributeDefinitions are entities in their own right. Subclasses of CustomAttributeDefinition define behaviour for a range of property types and contain things like descriptions and tooltips displayed to users when editing the values, constraints on the values that can be entered, ranges of values that can be selected etc. 
  
  
This supports things like:
  
  
- Values (String, Boolean, Int, DateTime etc)
  
- Lists of values (as above)
  
- MultiChoice (select from range of options (defined in CustomAttributeDefinition), with rules for min / max number of selections
  
- Measurement (amount / unit type)
  
- Dimension (width, height, depth, unit type)
  
  
A parallel hierarchy of CustomAttributeEditControls makes the editing experience within the UI a lot more pleasant, e.g. checkboxes for booleans (no more "Y/N, hmm or is it 1/0" in a text box), validation according to datatype etc.
  
  
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment28</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment28</guid><pubDate>Sat, 09 Aug 2008 20:38:29 GMT</pubDate></item><item><title>Mohamed Ahmed Meligy commented on Multi Tenancy - Extensible Data Model</title><description>In most cases I saw, people tend to choose "Extending the customer table" (with all new columns either allowing NULL or having proper default or in more advances scenarios getting default values from certain queries ran once when creating the additional column), changing from INT to STRING language code would be a migration plan that feels "normal".
  
  
Typically the migration would look like: creating another column with temp name, getting a query to set the new column values based on the corresponding old column values, and finally deleting the old column and renaming the new column to the old name if necessary. Clearly a down time thing, people sometimes avoiding by allowing the TWO columns to live probably forever, or until next version time (with acceptable idea of downtime) finally comes.
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment27</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment27</guid><pubDate>Sat, 09 Aug 2008 15:49:52 GMT</pubDate></item><item><title>Bunter commented on Multi Tenancy - Extensible Data Model</title><description>Jeremy, how does this solution differs from having partitioned ATTRIBUTE table with [attribute_id, attribute_type_id, owner_entity_id, value] ?
  
  
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment26</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment26</guid><pubDate>Sat, 09 Aug 2008 08:53:05 GMT</pubDate></item><item><title>Jeremy Gray commented on Multi Tenancy - Extensible Data Model</title><description>Again, it depends on the situation. I've worked with databases where the extra joins were feared as overhead but ended up being the optimal performing/scaling/maintaining/etc. option for a variety of reasons. This would appear to be yet another of those cases where everyone is right. ;)
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment25</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment25</guid><pubDate>Fri, 08 Aug 2008 18:02:25 GMT</pubDate></item><item><title>Tobin Harris commented on Multi Tenancy - Extensible Data Model</title><description>@Ayende
  
  
I agree! 
  
  
I meant to say I'm failing to communicate this to the rest of the team I'm working with. 
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment24</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment24</guid><pubDate>Fri, 08 Aug 2008 15:43:11 GMT</pubDate></item><item><title>Ayende Rahien commented on Multi Tenancy - Extensible Data Model</title><description>Jeremy ,
  
I understand what you are saying, but the cost of joins would be prohibitive to me. Adding ten columns == ten joins seems to be very costly
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment23</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment23</guid><pubDate>Fri, 08 Aug 2008 15:34:29 GMT</pubDate></item><item><title>Ayende Rahien commented on Multi Tenancy - Extensible Data Model</title><description>@Tobin,
  
Huh? Why are you going with all this complexity?
  
The flexibility you need is achievable, but the way you are going about is going to end in tears, from everything that I have seen
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment22</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment22</guid><pubDate>Fri, 08 Aug 2008 15:25:30 GMT</pubDate></item><item><title>Ayende Rahien commented on Multi Tenancy - Extensible Data Model</title><description>Eric,
  
Yes, I think it is alright to do this, yes.
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment21</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment21</guid><pubDate>Fri, 08 Aug 2008 15:19:09 GMT</pubDate></item><item><title>Jeremy Gray commented on Multi Tenancy - Extensible Data Model</title><description>Apologies if I could have been clearer. The approach I mentioned involves programmatically generating a new table for each custom field, rather than programmatically issuing alter table statements against a single Customer_Extended (or what have you) table. It takes a bit more metadata tracking, because you need to keep mapping information around so that each custom field can be mapped to its generated table. 
  
  
That said, it can be a net win in cases where row counts are high and alter table statements would cause too much work in the db, and/or if the custom fields are often null but your database server's packing of unused columns in rows sucks (Oracle handles this far better than SQL Server, for example), and/or if you want to spread custom field tables (and/or logs and/or indices) around different spindles, etc.
  
  
This model can be extended into multi-tenant scenarios quite nicely, and in fact gains a lot of leverage there especially you weren't planning on programmatically building and altering per-tenant Customer_Extended tables.
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment20</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment20</guid><pubDate>Fri, 08 Aug 2008 14:16:11 GMT</pubDate></item><item><title>Ayende Rahien commented on Multi Tenancy - Extensible Data Model</title><description>Jeremy,
  
Can you explain what this model is?
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment19</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment19</guid><pubDate>Fri, 08 Aug 2008 12:46:29 GMT</pubDate></item><item><title>Tobin Harris commented on Multi Tenancy - Extensible Data Model</title><description>P.S -On the subject of unstructured data, I quite like the direction these guys are taking:
  
  
http://strokedb.com
  
  
WARNING: That link may result in you seeing Ruby code :)
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment18</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment18</guid><pubDate>Fri, 08 Aug 2008 12:38:29 GMT</pubDate></item><item><title>Tobin Harris commented on Multi Tenancy - Extensible Data Model</title><description>@Ayende / @josh
  
  
Thanks for the feedback. 
  
  
As you say, this model won't perform well. That was anticipated, and the solution is to export data to an optimized read-only runtime db to get realistic live web-site performance. 
  
  
It's the complexity that I'm most uncomfortable with. Delivering understandable &amp; maintainable code is hard enough (for me at least!). I fear attempting to do it on top of a meta-layer will just makes it harder. The meta layer does add value, but it comes at a cost.
  
  
Also, the exported live database will need to be mapped into c# objects to give us any kind of maintainable &amp; understandable way of using the CMS data in web pages. So we need to write a mapping layer to generate the live db from CMS data, then generate/write objects, and then generate a mapping layer to get them out of the live db. Then we need to find a home for the small(ish) amount of  business logic in the apps.
  
  
I've been questioning if the oober flexible CMS back-end is worth the complexity of having all this extra work, but I'm not communicating well enough and haven't managed to collect and express my arguments successfully. I'll keep at it... 
  
  
Thanks again
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment17</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment17</guid><pubDate>Fri, 08 Aug 2008 12:34:23 GMT</pubDate></item><item><title>Jeremy Gray commented on Multi Tenancy - Extensible Data Model</title><description>Of the options you listed  "Customer_Extended" is the one I've seen work best over the years. Of the options you _haven't_ listed, going fully table-generational on a per-tenant-per-custom-field basis has tended to work even better still, though occasionally at some cost due to the overhead of larger numbers of joins. That said, the join overhead has almost always been offset by better data locality, lower data page count, options for more effective indexing (and lower re-indexing overhead in high insert scenarios), etc.
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment16</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment16</guid><pubDate>Fri, 08 Aug 2008 05:35:15 GMT</pubDate></item><item><title>Eric Hauser commented on Multi Tenancy - Extensible Data Model</title><description>Ok, so now that we are on the same page on terminalogy =).  My question is do you think it is a good idea to have an action by a customer (be it an admin or just a regular users) do something that ends up executing a DDL statement?  I'm not saying that this is a bad thing, but I would approach it with some skepticism.
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment15</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment15</guid><pubDate>Thu, 07 Aug 2008 23:58:37 GMT</pubDate></item><item><title>josh commented on Multi Tenancy - Extensible Data Model</title><description>Tobin,  I agree with Ayende.  I've been down the xml in the database several times.  It's mostly not worked out.  I have a specific case that I'm using it for now, but it's very limited and has nothing to do with extensibility.
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment14</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment14</guid><pubDate>Thu, 07 Aug 2008 23:01:31 GMT</pubDate></item><item><title>Mike D commented on Multi Tenancy - Extensible Data Model</title><description>Thanks, from where I sit it's nice to see a dev as smart as yourself arriving at the same conclusions...
  
  
Keep this topic going if you have the time, hopefully we can hire you for a code review.
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment13</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment13</guid><pubDate>Thu, 07 Aug 2008 21:48:29 GMT</pubDate></item><item><title>Ayende Rahien commented on Multi Tenancy - Extensible Data Model</title><description>Eric,
  
Even with salsforce, it is the tenant admin that does that.
  
I as a standard user do not do that
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment12</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment12</guid><pubDate>Thu, 07 Aug 2008 21:38:42 GMT</pubDate></item><item><title>Eric Hauser commented on Multi Tenancy - Extensible Data Model</title><description>I think that sort of customization (custom extension for a particular tenant) occurs a lot less frequent than the end user (the customer) adding fields to their entities.  Something like Salesforce.com comes to mind as an example where this is done all over the place.
  
  
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment11</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment11</guid><pubDate>Thu, 07 Aug 2008 21:19:13 GMT</pubDate></item><item><title>Ayende Rahien commented on Multi Tenancy - Extensible Data Model</title><description>Tobin,
  
I would strongly recommend against this approach. It has horrible performance issues when you try to scale it, the complexity is huge, joining is not possible, etc.
  
If you want unstructure data, don't use a DB
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment10</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment10</guid><pubDate>Thu, 07 Aug 2008 21:17:34 GMT</pubDate></item><item><title>Ayende Rahien commented on Multi Tenancy - Extensible Data Model</title><description>Eric ,
  
Yes and no.
  
The "end user" in this case is the tenant administrator, not just any random joe user.
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment9</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment9</guid><pubDate>Thu, 07 Aug 2008 21:09:43 GMT</pubDate></item><item><title>Ayende Rahien commented on Multi Tenancy - Extensible Data Model</title><description>Mike D,
  
For some reason I got a lot of contacts for multi tenancy stuff lately, and it _is_ an interesting subject.
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment8</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment8</guid><pubDate>Thu, 07 Aug 2008 21:04:53 GMT</pubDate></item><item><title>Ayende Rahien commented on Multi Tenancy - Extensible Data Model</title><description>Chad,
  
This is just a variation on the extended table, as far as I can see.
  
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment7</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment7</guid><pubDate>Thu, 07 Aug 2008 21:02:37 GMT</pubDate></item><item><title>josh commented on Multi Tenancy - Extensible Data Model</title><description>Honestly,  I only glazed over the first in this series and skipped the second.  I wasn't sure where you were going and didn't think it applied.  But this one hit the "I've been there" button.
  
  
I'm working with an app that has a rather complex (due to necessity) data structure.  It supports user and 3rd party customizations down to the database level  We have a well normalized schema, and allow what we call dynamic tables to extend our entities.  For instance, our Contact entity is defined by data from a contact table and additional info in tables like Address, and Phones.  The tables that define or extend the entity are tracked by an entity definition table that contains information regarding the system and extended tables that belong to an entity.  
  
  
I have an add-on that we develop for the product which adds two additional fields to the contact entity, which are stored in its own table.  We maintain a contact view that rebuilds as needed based on information in the entity definition table.  
  
  
Our model classes are mutable types that are partly defined by mutable field descriptors.
  
  
In our case, the app or addon does modify the database schema on the fly, but it is abstracted to help keep accessing the database straight forward.  Maybe I'm misunderstanding, but it sounds like what you describe as the extended table approach.  it works, and the performance in the database and framework is pretty decent/good.  
</description><link>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment6</link><guid>http://ayende.com/3498/multi-tenancy-extensible-data-model#comment6</guid><pubDate>Thu, 07 Aug 2008 17:18:42 GMT</pubDate></item></channel></rss>