The file which contains the day to day activities of each employee. And it shows the detailed description of employee what they done at work time. So these files are prepared by employee.
Now, my requirement is how to design a database for this model. I know only the basics of databases and yet I didn't design any databases. So any one help me to solve how to create a database design for the application.
The design should also work for the query to get details about individual employee like
For Ex:
-
Total time spent by the shiva 'shiva' on CCTNS project
-
To find the team leader for the specified project
-
To find the members in a particular project
Best Answer
I would suggest two fundamental tables for this purpose, if you're creating this all from scratch. This assumes that this is being created in PostgreSQL.
An employee table containing their name and whatever other details are important for your application, with a numeric primary key. The primary key is important because you may have more than one employee with the same name, and you may have employees that change names in the future. Using a key allows the information about their time to remain consistent.
An activity log table containing:
SERIAL
is likely fine for this)tstzrange
column to represent the period for the log entryNow this schema doesn't contain enough information to identify a team leader. You could add this information to another table, referencing your employee (and possibly project) table.
Here's a quick example schema you can play with: