(no title)
new_test | 12 years ago
Here's a concrete (made-up) example: I want to write a webapp where people would sign up to do some personal tracking. They create variables they are interested in (weight, mood, calory intake, etc.) And then enter their data daily. So for each customer I need to have a different database with different columns, and I want them to be able to add/delete variables "on the fly". Is it very straightforward, and hard to get wrong? Or are there "best practices" for this sort of thing? Thanks.
dragansah|12 years ago
[1] Generic Data Model: http://c2.com/cgi/wiki?GenericDataModel
bananas|12 years ago
1. SaaS tenancy models. This is the data separation.
2. Custom fields would be usually represented as an EAV model (Entity-Attribute-Value).
3. Don't ALTER in production if you can help it. If you're going to do it, use migrations which are scripts which first add columns, then transform data, then reapply constraints.
arethuza|12 years ago
From what I've seen, applications that use EAV tend to evolve to suffer from bad cases of the "inner platform effect":
http://en.wikipedia.org/wiki/Inner-platform_effect
NB There is nothing "wrong" with using EAV - just that it seems prone to misuse (a bit like XML).
bennylope|12 years ago
If you really need to separate data by customer then consider using PostgreSQL schemas. But I'd steer away from any solution that involves adding and dropping columns for different customers.
mwhite|12 years ago