Hourly Time Sheets Database Design - database

Building an internal web-based project management tool for my company. Need some help with the database design for the timesheet component.
We currently use an MS Excel file where:
Column headings - Days of the week
Rows - Time of the day with 30 minutes per row (Row1: 9:00AM, Row2: 9:30AM and so on)
Each cell in the table has a dropwdown menu that fetches from a set of predefined tasks set by a manager and the employee selects one of the tasks against that day and that particular 30 minute time slot.
I want the front end interface to remain the same for the employees.
Need help with designing a database that supports this. I'm open to any suggestions/changes in the restrictions I laid out if it allows for better efficiency. Thank you!

Is something like this what you're after?
Task (all of the tasks an employee might be assigned)
PK: Id
Name
... other details ...
Employee
PK: Id
Name
... other details ...
EmployeeTask (the list of tasks that have been assigned to an employee)
PK: Id
FK: TaskId
FK: EmployeeId
TimePeriod (the row labels)
PK: Id
Start (9:30, 10:00 etc.)
Timesheet (chops out a region of time and says it's one thing - gives column headings)
PK: Id
Start date
End date (don't need this if timesheets cover the same length of time)
EmployeeTimesheetCell
PK: Id
FK: TimesheetId
FK: EmployeeId
FK: TimePeriodId
FK: TaskId
Date or day of the week
Time spent
You'd probably want some kind of status or Finished Date on Task and/or EmployeeTask, so that old finished tasks don't clutter up the GUI.

Related

Return number of first-time purchases on a date

In Google Data Studio, I'm reporting on data which shows purchases (well, really donations) over a particular time frame. Each purchase shows a transaction ID, the customer ID who made that purchase, and the date of their first purchase.
What I'm trying to do is to get the number of first-time purchases over the course of the report date range. So I want to see how many purchases were made over the date range AND how many of those purchases were customers that were purchasing for the very first time. ie, "Dec 3, 2020: Purchases: 40. First-time purchases: 17."
How can I do that in a Data Studio field when that first-purchase field is always populated with something?
Thanks!
With the information you provided, I suppose your Data Source also has a column named Purchase Date (which stores when that particular transaction happened).
Assuming this is true, you can create a new calculated column with the difference, in seconds, between the purchase date and the first purchase date:
Column First Purchase Diff: DATETIME_DIFF(Purchase Date, First Purchase Date, SECOND)
With this column, you can easily detect if that particular transaction is the first purchase (=zero difference between dates), with a new calculated column:
Column Is First Purchase: CASE WHEN First Purchase Diff = 0 THEN 1 ELSE 0 END
Now, just summarize the number in this column to show how many first purchases (or donations) you have in a particular period.

Data warehouse design: how to design fact and dimension table with changed delivery date

I am trying to create a PO info data warehouse but i am facing problems with the vendors delayed deliveries. I would like to track the changes when the vendor late on delivery and change the delivery date. How should i organize the table to track the changes, should i put the delivery date in a dimension table or fact table? any help will be appreciated.
I'd just put everything in a single Purchase Order table.
Purchase Order
-------------_
Expected Delivery Timestamp
Actual Delivery Timestamp
Purchase Order ID
Purchase Order Creation Timestamp
...
The primary key would be (Expected Delivery Timestamp descending, Purchase Order ID).
You would create another unique index on (Actual Delivery Timestamp descending, Purchase Order ID, Expected Delivery Timestamp).
This single table would allow you to write queries like, "How many deliveries were more than a week late in the 2nd quarter of 2016?"

One to many relation in database with common related table

Imagine that I have a Table Cine. It holds name, director, etc. of movies. It can start and finish in any time, and this time is created dynamically, in another Table: Schedule.
Thus, between Cine-Schedule there is One-To-Many relation. So, this would be solved by adding Foreign Key to Schedule. Some thing like this:
Cine
ID Name
1...Matrix
Schedule
CineID. From To...... WeekDay
1.. ........17.00. 19.00..... Wednesday
1...........20.00. 22.00.....Thursday
Now imagine that another table also wants to use this Scheduling, which is conceptually totally separated from Cine, let say CarRevision.
In this case, how would be "better design" of database.
Adding another foreign ID to Schedule?
Schedule
CineID. RevisionID From To...... WeekDay
1.. .........Null.............17.00. 19.00..... Wednesday
1............Null.............20.00. 22.00..... Thursday
Null.........325............14.13. 14.34..... Monday
Creating another table, like RevisionSchedule, same with Schedule, but with -logically- different foreign ID?
Other solution? What about if we have many -conceptually- different Tables that want to use Schedule?
for proper normalization, you would remove cine_id from the schedule - since it is not directly part of the definition of a schedule
you would make a new table
cine_schedule
--------------
cine_id
schedule_id
start_date
end_date
you would also build other relationships as appropriate
car_schedule
--------------
car_id
schedule_id
etc.

Employee School Attendance in payroll system database schema

I have payroll system with attendance log-in and log-out, am and pm.
These are the tables:
DTR: list of all emloyees with there log-ins and log-outs for the day
Date Empid timein_am timeout_pm timein_pm timeout_pm status tothrslate
12-4-13 1000 7:00 12:00 1:00 5:00 log-out 0
dtrlogs:
Columns are equal with the dtr tables. The attendance above will be moved here after the employee made an attendance for the day.
This table is list of all attendance of all employees everyday.
After the records of dtr table will be moved here, the time-ins and time-outs status, tothrslate will be deleted for the next day.
Questions:
Is it a good idea to have a dtrlogs in my database schema?
In any sense, is there anyway to do this for my attendance?
Btw, my client application is vb6 and I am using msaccess. Im just having a hard time designing database for payroll with attendance. I want to record all attendances of an employee everyday in a table. I was thinking to store attendances by months, meaning, I will have to create tables Jan-Dec. But I don't know if this is a good idea. Any advice? Any help would be apreciated.
The first thing I noticed was that your DTR table is very restrictive. What if a boss decides that everyone needs to clock out when they take smoke breaks? With your DTR table, the employee can only clock in and out once in the afternoon.
You also need an Employee table with the employee's ID, name, phone number, emergency contact, etc.
I recommend 1 source table to hold your permanent data. It will never be deleted. Give it 3 fields:
EmpID
Clock_In
Clock_Out
This allows multiple 'work periods' during the day, including if someone skips lunch completely. From this 1 table, you can schedule a nightly process that will clock out people who forget, build daily and monthly summaries, etc.
I also imagine this is a fairly common task. Try googling it.

Database designing help for billing system

I am developing a Electronic Bill Payment System for a bank which has more than 100 customers subscribing for Electronic Bill Payment.
I have a table in which I am creating profile for customer like the following.
Customer Table
Customer_ID (Primary key)
Customer_Name
Address
Phone
Bill_Master
Customer_ID
Enrollment_Date
UtilityCompany_ID
Bill_Generation_Date (lets say 18th of every month)
Bill_Due_Date (lets say 27th of every month)
Our_CutOff_Date (when the bank will generate the bill for payment)
I have created the customer along with clue that which utility company's bill generates on which date and what will be the due date of EVERY MONTH.
I want to create an interface where the user will see the entries of all the customers whoz date is due for bill generation and after that user will click on the particular entry and generate the bill manually by entering the amount and other details so for this I am clueless how to find out which customer's utility company bill is due for generation..
Any help how should I design it and query of it? or would be a automatic procedure like job or something which will do it.
thanks
Well if its a query you need to generate bills that are due 27th of every month and also find the customer's utility company, then you can try this -
SELECT A.Customer_Name, B.UtilityCompany_ID FROM
Customer A inner join Bill_Master B on A.Customer_ID = B.Customer_ID
WHERE Bill_Due_Date BETWEEN GETDATE() AND DATEADD(MONTH,-1,GETDATE())

Resources