My Requirement I need to design a database that handles multiple time sheet formats for different clients. Some of the fields in TimeSheet are the same for some clients and different for others. Also, each client's time sheet may have unique fields. For example:

Client 1 ==> EmpID, Date, Start Time, End Time,Verifier, Supplier Name ...
Client 2 ==> EmpID, Date, No.Of Hours, Project Code, Project Manager ...
Client 3 ==> EmpID, Date, Time In, Time Out, No of Hours Worked, Verifier...
Client 4 ......................................................
Client .. ......................................................

My Query

How should I design the TimeSheet table to accommodate the existing clients or future clients that may get added (not a major concern at this point)

  1. Should all the fields related to all clients be in one table, TimeSheet?
  2. Or should I have a main table TimeSheet with all the common columns, and then additional tables corresponding to each client, to contain the specific fields for that client?
  3. In case I need to have TimeSheet child tables for a future client who would need to have more than one entry per day specific to project tasks how should be incorporated?
  4. Any tips on good practice?

There is no perfect answer for this only you can decide the best option. And it has a lot to do with tradeoffs, and preferences. How much time you have now vs maintenance in the future.

You could have:

  1. 1 table for all customers.
  2. A table(s) for each customer
  3. A database for each customer.

Option 1 is ideal if you hope to reuse and resell to many customers. The downside is that you cant use the db schema to enforce rules per column unless the rule applies to all customers. Which makes enforcing business rules difficult.

Option 2 allows you to use the schema to enforce rules per customer. But the queries and app design become more complex.

Option 3 means you can create a customised solution per customer, but it will require more effort to maintain.

Start by modelling the requirements and see how much commonality there is and what is or is not mandatory.

Understanding business rules and things like one to many relationships will be key to getting it right.

If you dont expect the db to enforce mandatory fields and can handle that in the application personally i would lean towards option 1 with as much re-use as possible.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.