- Feb 17, 2002
- 4,723
- 80
- 91
Hey guys. So I'm tinkering with an idea for an app, but I'm a bit stumped for a good approach for the back-end. I have a good schema/data model already, but it's only set up for one user. For this app to work using my existing techniques, algorithms, and data model, each user needs its own database, basically. For scalability reasons, giving each user it own micro-db like SQLite is out of the question (i.e. I don't want one instance per user).
The naive approach is to simply add the user ID to each table's primary key, which would also be a foreign key to a parent user table. I'm worried about the performance implications of this, however. I'm not really sure how this would affect real-world DB performance - is there some kind of clever partitioning and indexing we could do to mitigate the performance penalty?
Another approach is to normalize a bit more, where only one table has a reference to the parent user table, then each child references it. I would be worried about the join calculus here since we'd automatically be introducing two joins for any query. And really, each user's records are completely unrelated. A textbook would say that this is the right answer, but I just don't buy it.
What other approaches would you recommend?
If it matters, I'm planning on targeting MS SQL Server 2012 and the whole thing would be written using Entity Framework.
Thanks!
The naive approach is to simply add the user ID to each table's primary key, which would also be a foreign key to a parent user table. I'm worried about the performance implications of this, however. I'm not really sure how this would affect real-world DB performance - is there some kind of clever partitioning and indexing we could do to mitigate the performance penalty?
Another approach is to normalize a bit more, where only one table has a reference to the parent user table, then each child references it. I would be worried about the join calculus here since we'd automatically be introducing two joins for any query. And really, each user's records are completely unrelated. A textbook would say that this is the right answer, but I just don't buy it.
What other approaches would you recommend?
If it matters, I'm planning on targeting MS SQL Server 2012 and the whole thing would be written using Entity Framework.
Thanks!