Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Schema for storing data for several unrelated entities.  RSS feed

 
stepan Le
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Database examples dealing with a store with customers and orders places all customers in one table. Then it places all goods in another table and makes a many to many Customers_Goods table. This works when each customer has little data associated with them, so making a separate schema for each customer wouldnt pay off.

What about a case when one builds a db for several companies. Lets say there are  50-100 companies total each requiring 10 identical tables (EmployeeID, Departments, Address,..) with 100000 entries for largest companies? Keeping employeeID in the same schema for all companies seems impractical. Should a schema be created for each company in this case? How to automatically create a schema for each new company? Can you recommend a relevant textbook or tutorial?
 
Knute Snortum
Sheriff
Posts: 3545
85
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would need to know more about the situation, but if there were no instances of an employee being in two companies, then my gut says to have separate tables for a company.  Your application would have a Create a New Company function in which all table would be created.

Otherwise, you could have an employee to company table.  The downside to this would be every time you wants to do something with an employee, you would have to join the employee to company table and select on company.  This could slow down your whole system.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!