title: How do I keep user specific data separate in my database?
body: <p>I'm in the planning phase of designing an app that will involve users registering with my website and storing data. I've decided on using Spring and Hibernate but I have a couple questions for which I would like to get answers.</p>
  
  <p>My first question involves data separation. When a user registers with my site, they will be able to store data imported from another source. The amount of data (number of rows) for each user will grow very fast. If I store all user data in a single database I expect to run into performance problems very quickly. To address this, I was planning to create a new database for each user that signs up. This would happen on the fly via some script or other programmatic solution. Is this feasible? Does anyone know of any design pattern that addresses this problem?</p>
  
  <p>My second question is related to my first question. If it is feasible to create a new database for each user, how will this work with hibernate? Obviously I won't restart my application every time a new user signs up. Can hibernate be configured dynamically to connect to a different database based on some criteria (currently logged in user)? If I have two users logged in simultaneously, the expected behavior would be that each user only have access to data in their database.</p>
  
  <p>Thanks. </p>