I'm looking for a bit of general advice on an approach here.
Say I have a table layout that is like:
Name | 1hr | 2hr | 3hr | 4hr
---------------------------------
Joe | 23 | 12 | 45 | 9
The hours refer to an hour ago. Or 3 hours ago. And I will be updating this data every hour. I'll be doing this with many rows. Now each time I update I will move the values to the right. So 1hr becomes 2hr etc. And 1hr is then inserted as new.
My questions is this, instead of updating each cell and then the new value is inserted what would be the most efficient way of doing this? I will be using Java and JDBC as to control these operations.
My initial though is to treat it like you would a circular array. Have an extra cell to hold a pointer to the start. This would result in 2 updates per operations vs 4.
Is this a good approach or is there something better?
The better approach would be to store another table:
Name | Time | Value
--------------------
Joe | 10:00 | 9
Joe | 11:00 | 45
Joe | 12:00 | 12
Joe | 13:00 | 23
Then you don't have to do anything to update, you just add a new row when you want to add a value.
Related
I'm trying to figure out conditional formatting to compare time logs, looking for outliers.
3 columns date, startTime, endTime to be compared against 3 similar columns
(Trying to highlight team members who worked alone during their logged hours)
I feel like I am dancing around a correct solution, but can't seem to nail it.
The simple version for conditional formatting that works for a single column is:
for column A: =COUNTIF($C$2:$C$9,$A2)=0
for column C: =COUNTIF($A$2:$A$10,$C2)=0
But, I am comparing 3 columns (date, startTime, endTime) from 1 person against a similar time log from different people...
Each member of a team is required to work with at least one other member at any given logged time. So, I only want the format change if the entry does not have a matching (date & start & end) from another person on the team.
Technically, I have up to 8 people in a team. But I think I can manage setting additional formatting after I understand the first set of columns.
I would compare by hand, but I have over 300 teams of up to 8 people. I have their logs on individual tabs, up to 8 per spreadsheet (one team). I added a total's sheet placing date, start, and end for person 1 in in columns a,b,c and person 2 in e,f,g etc....
I've tried many various combinations of countifs, countif with transpose, countif with join, countif with "&".
The most recent version was:
=COUNTIF(transpose($G$3:$J),transpose($B3:$E))=0
But, most, like this one, only seem to highlight if the date is different. If the date is the same and the hours differ it doesn't seem to see it.
I'm pulling time logs into my totals page with arrayformulas. I tried at one point to join the data into a string in a single column as it was being pulled in, but either the dates were getting changed to strings of numbers or the data was too squished and I couldn't read it clear enough while reviewing.
| x | date A | Start B | End C | D | date E | Start F | End G |
|:-:|:-------:|:-------:|:-----:|:-:|:-------:|:-------:|:-----:|
| *| 9/7/22 | 10am | 11am | | 9/7/22 | 2pm | 3pm |
| | 9/7/22 | 2pm | 3pm | | 9/10/22 | 2pm | 4pm |
| *| 9/8/22 | 2pm | 3pm | | 10/2/22 | 10am | 11am |
| | 9/10/22 | 2pm | 4pm | *| 10/3/22 | 9am | 11am |
| | 10/2/22 | 10am | 11am | | | | |
* = Highlight where not found in other lists
I tried an apps script, but had to authorize it for every spreadsheet hiding the functions from users not on review committee (roughly 300 spreadsheets).
The totals page will be hidden from the people logging their hours. I will not be reviewing the hours worked, there is a committee of 3 reviewing. I didn't want all 3 to have to authorize 300 spreadsheets.
//??????????????????????????????????????????????????????????
TLDR:
Please help me build a conditional format formula like:
(for column A: =COUNTIF($C$2:$C$9,$A2)=0)
that will take the combined values of 3 cells ABC and highlight any row that doesn't have a matching combined EFG.
//???????????????????????????????????????????????????????????
Any help would be greatly appreciated. Thanks!
If you could create a new column with this formula that joins E,F and G:
=arrayformula(IF(E2:E="","",E2:E&"|"&F2:F&"|"&G2:G))
I've set it in H:
Obviously you can hide that column, and yes, it is posible to do all inside the conditional formatting itself without that column but calculations will slow down a lot. You can change H to another column, just be sure that you change it in the formula too.
Then you can set this conditional formatting in range A2:C that joins each row and compares to that new column.
=IF($A2="","",if(iferror(match($A2&"|"&$B2&"|"&$C2,$H:$H,0),0),false,true))
See it here
I have a complex(?) SQL query I am needing to build. We have an application that captures a simple data set for multiple clients:
ClientID | AttributeName | AttributeValue | TimeReceived
----------------------------------------------------------------
002 | att1 | 123.98 | 23:02:00 02-03-20017
----------------------------------------------------------------
003 | att2 | 987.2 | 23:02:00 02-03-20017
I need to be able to return a single record per client that looks something like this
Attribute | Hour_1 | Hour_2 | Hour_x |
--------------------------------------
att1 120.67 |
--------------------------------------
att2 | 10 | 89.3 |
The hours are to be determined by a time provided to the query. If the time was 11:00 on 02-03-20017, then hour 1 would be from 10-11 on 02-03-20017, and hour 2 from 9-10 on 02-03-20017. Attributes will be allocated to these hourly buckets based on the hour/date in their time stamp (not all buckets will have data). There will be a limit on the number of hours allocated in a single query. In summary, there are possibly 200-300 attributes and hourly blocks of up to 172 hours. To be honest I am not really sure where to start to build a query like this. Any guidance appreciated.
I am looking to create a booking system. On one end you have a client looking to book an appointment and on the other end you have a provider who has a schedule that a client can book against
When signing up as a provider they are allowed to pick their days of work and hours. They have html check-boxes which represent which days they can select and once they select a day the hours are are displayed (drop-downs in angular) as you can see below
html schedule form
On the MySQL side I am thinking I can have a table which has a column for each day and have a comma separated list in there for the start time, end time, lunch time and lunch length
i.e. Provider selects Monday and Tuesday to work from the hours below
Provider 'Schedule' Table
|ScheduleID|ProviderID|Monday |Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday|
|----------|----------|--------|--------|---------|--------|------|--------|------|
|1 | 2 |09:00am,|10:00am,| | | | | |
| | |08:30pm,|07:00pm,| | | | | |
| | |12:00pm,|01:00pm,| | | | | |
| | |30 min |60 min | | | | | |
|----------|----------|--------|--------|---------|--------|------|--------|------|
The table would have a schedule id and a provider id which links back to the "provider" table to link the provider to his schedule
Or is this better?
|-------------|-------------|----------|-----------|----------|------------|--------------|
| schedule_id | provider_id | week_day |start_time | end_time | lunch_time | lunch_length |
|-------------|-------------|----------|-----------|----------|------------|--------------|
| 1 | 1 | Monday | 06:00 AM | 08:00 PM | 12:30 PM | 60 |
|-------------|-------------|----------|-----------|----------|------------|--------------|
| 2 | 1 | Friday | 06:00 AM | 08:00 PM | 12:30 PM | 60 |
|-------------|-------------|----------|-----------|----------|------------|--------------|
| 3 | 2 | Tuesday | 06:00 AM | 08:00 PM | 12:30 PM | 60 |
|-------------|-------------|----------|-----------|----------|------------|--------------|
if not post something that is
Before I go into how I believe you should structure your Provider 'Schedule' Table, please make sure to, in the future, remove fluff.
More on fluff here.
It may serve you better to make the following changes:
make all column headers lowercase, as this might prevent errors if you attempt to query your database another way
change scheduleId to id
Instead of having seven columns, one for every day of the week, you could simply put a weekDay column that stores the value of that weekday
Then create columns for startTime, endTime, lunchTime and lunchLength
Finally, create a scheduleId column that ties together all the different weekday rows of someone's schedule to one provider
Some considerations:
Instead of having strings "Monday" or "Sunday" in the weekDay column you could instead insert 0..6, where 0 is a Sunday and 6 is a Saturday to make it more compatible with other languages
You could always just keep scheduleId in this table and create another table with the individual schedule days and link them with a foreign key, but this might prove to cause more problems than it's worth
Keeping that lunchLength as just an integer, as that will make everything easier
The reasoning behind splitting up the data as much as possible is because if you are querying using another language you might need to go through all the extra work of splitting those Monday and Tuesday columns if you just want the startTime for instance.
Hopefully the above is either a solution or allows you to consider another approach.
Here is a Java Android Library that you can convert into JavaScript: https://bitbucket.org/warwick/schedule_utils_demo/src/master/
Running the code in a client side language will save your server the burden as scheduling code is very inefficient.
Hope this helps.
I have a database schema like this:
sms_queue
---------------
id
status
Date Time
How do I arrange codeigniter active record to update the status only for the passed day (date time) the reference time is the time when I call the function?
Let say according to my time zone, it is on 11-01-14 (11th january 2014), and i have 5 tuple.
sms_queue
+----+--------+----------------+
| id | status | Date Time |
+====+========+================+
| 1 | unsent | 15-01-14 18:45 |
| 2 | unsent | 02-01-14 08:15 |
| 3 | unsent | 01-01-14 07:00 |
| 4 | unsent | 11-01-14 09:00 |
| 5 | unsent | 13-01-14 07:00 |
+----+--------+----------------+
what where clause on active record / sql statement should i use to select only for the second and third data above assuming today is 11-01-14
i mean the query must be like this
$this->db->where(blablabla)
->update('sms_queue',array('status'=>'sent'))
so what is the blablabla
i hope the answer is using active record not a sql statement since it says that using codeigniter active record is more safer for security issue.
Finally i could answer my own question and found the solution for my specific problem.
i use this one
$this->db->where('Date time <',date(Y-m-d))
->update('sms_queue',array('status'=>'sent'));
The query will update the status to be sent for every item who have the date time on the past day of today.
Sorry if my question is not so clear. Sorry for my bad english.
Objective: Convert an overgrown Excel sheet into an Access database, but maintain a front-end that is familiar and easy to use.
There are several aspects to this, but the one I'm stuck on is one of the input forms. I'm not going to clutter this question with the back-end implementation that I have already tried because I'm open to changing it. Currently, an Excel spreadsheet is used to input employee hour allocations to various tasks. It looks something like the following.
Employee | Task | 10/03/10 | 10/10/10 | 10/17/10 | 10/24/10 | ... | 12/26/11
---------------------------------------------------------------------------------
Doe, John | Code | 16 | 16 | 20 | 20 | ... | 40
---------------------------------------------------------------------------------
Smith, Jane | Code | 32 | 32 | 16 | 32 | ... | 32
---------------------------------------------------------------------------------
Doe, John | Test | 24 | 24 | 20 | 20 | ... | 0
---------------------------------------------------------------------------------
Smith, Jane | Test | 0 | 0 | 16 | 0 | ... | 0
---------------------------------------------------------------------------------
Smith, Jane | QA | 8 | 8 | 8 | 8 | ... | 8
---------------------------------------------------------------------------------
TOTAL | 80 | 80 | 80 | 80 | ... | 80
Note that there are fifteen months of data on the sheet and that employee allocations are entered for each week of those fifteen months. Currently, at the end of the fifteen months, a new sheet is created, but the database should maintain this data for historical purposes.
Does anyone have any ideas on how to create an editable form/datasheet that has the same look and feel? If not, how about an alternative solution that still provides the user a quick glance at all fifteen months and allows easy editing of the data? What would the back-end tables look like for your proposed solution?
This is a classic de-normalization problem.
To produce an editable spread-sheet like view of your database you'll need a table with 66 columns (the two identifying columns and 64 weekly integer columns). The question is whether you want the permanent storage of the data to use this table, or to use a normalized table with four columns (the two identifiers, the week-starting date, and the integer hours value).
I would give serious consideration to storing the data in the normalized form, then converting (using a temporary table) into the denormalized form, allowing the user to print/edit the data, and then converting back to normal form.
Using this technique you get the following benefits:
The ability to support rolling windows into the data (with 66 columns, you will see a specified 15 month period, and no other). With a rolling window you can show them last month and the next 14 months, or whatever.
It will be substantially easier to do things like check peoples total hours per month, or compare the hours spent in testing vs QA for an arbitrary range of dates.
Of course, you have to write the code to translate between normal and denormal form, but that should be pretty straightforward.