Author |
Topic  |
snaayk
Senior Member
   
USA
1061 Posts |
Posted - 19 February 2002 : 20:21:13
|
I am not sure if I would call it a web application. What I am trying to do is keep track of some guys that work for me. Keep track of how many jobs are completed in a day, how much OT, how many dispatches etc. Now it gets tricky. I was asking our IT guru if he could set me up with an ASP server on the intranet, now I am stuck doing this for more ppl than anticipated.
Now what would be the best way to add and query the following data:
4 groups 7 sub-groups in each group 15 employees in each sub-group.
I have to add on a daily basis one record for every employee. This data is going to be queried different ways for the info needed.
A simple entry of 3 records in 3 different subgroups.
Group# | Emp# | Date | Total Hrs | OT | Exempt Hrs | Total Tasks | Tasks not Completed 6 | 204 | 1/21 | 8 | 0 | 0 | 8 | 0 1 | 101 | 1/21 | 10 | 2 | 0 | 6 | 1 3 | 356 | 1/21 | 12 | 4 | 0 | 10 | 2
Now, if you did the math you will notice that there will be a daily total of 400 records added.
The queries would call for:
data from one/some sub-groups data from one/some groups data from all groups
The query would be something like how much OT from one subgroup to how much OT for one group. Also, there will be a query that will say how many tasks did one employee make divided by the hours worked (That will take some other researching on math in sql/asp) or what did an entire group make (tasks divided by total hours)(actually I will have to perform a formula for achieving the total score that they are rated on)
The question what is the best way to add and store the data. I was thinking perhaps a table for every subgroup and then using inner-joins on some of the queries. It would be easier to have one table but I think that 400 records added a day by 30 days might be a bit much. For the Access db and as well the queries that would be run.
The other issue is how would I go about adding a separate record for each employee, one after the other. For example, when I am going to input my data for my group, I would want to do one after the other or at the same time, opposed to clicking a link for each employee was I went adding. Can this be done o one page? Or do separate pages need to be generated?
Any help you guys/gals can give would be great, I am quite at a block on how to START tackling this.
|
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 19 February 2002 : 20:33:06
|
quote: The question what is the best way to add and store the data. I was thinking perhaps a table for every subgroup and then using inner-joins on some of the queries. It would be easier to have one table but I think that 400 records added a day by 30 days might be a bit much. For the Access db and as well the queries that would be run.
Sorry to disagree on that. I would go for the "immediate" organization: a table for groups, another for subgroups, another for employees and a fourth for employee daily data.
Man, Access is a real database. Your 400 records are really small in size (just look at the data for each record). Structure your database properly, create the adequate indexes, compact the database regularly, and you should have no problems.
Going for a "non-orthodox structure will complicate the coding enormously and I don't see the benefits from that. Remember: there are people who have tens of MB in Access databases, without a single problem. Access is a database and a nice one too, specially for the kind of small scale task you are looking for...
|
 |
|
Nikkol
Forum Moderator
    
USA
6907 Posts |
Posted - 19 February 2002 : 20:45:56
|
First, you could set your db up with the following tables:
Groups ------- GroupID (Autonumber-Primary Key) GroupName (Text)
SubGroups --------- SubGroupID (Autonumber-Primary Key) GroupID (Number) SubGroupName (Text)
Employees --------- EmployeeID (Autonumber-Primary Key) FirstName LastName HourlyWage ... (and any other field you might want for that employee)
EmployeeGroups -------------- EmployeeID (Number-Primary Key) SubGroupID (Number-Primary Key)
DailyActivity ------------- ActivityID (Autonumber-Primary Key) EmployeeID (Number) Date (Date/Time) TotalHrs (Number) OverTime (Number) .... (and any other fields you might want) SubGroupID (Number) - you need this only if you have employees that belong to more than one SubGroup
That's the first part. Making the queries work is a whole new ballgame. I'll reply again after thinking it through some more. But to answer your question about being able to key it in on one page, that may very well be possible....
More to come...
Nikkol |
 |
|
snaayk
Senior Member
   
USA
1061 Posts |
Posted - 19 February 2002 : 20:59:21
|
Ok, that makes sense.
quote: Man, Access is a real database. Your 400 records are really small in size (just look at the data for each record). Structure your database properly, create the adequate indexes, compact the database regularly, and you should have no problems.
So, 12,000 records a month isn't all that much (considering the size of the data)? That's good to know.
I guess I would then begin using inner joins for some of the queries that pull data from the multiple tables? Like total OT for all the group?
|
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 19 February 2002 : 21:13:59
|
quote:
First, you could set your db up with the following tables:
Groups ------- GroupID (Autonumber-Primary Key) GroupName (Text)
SubGroups --------- SubGroupID (Autonumber-Primary Key) GroupID (Number) SubGroupName (Text)
Employees --------- EmployeeID (Autonumber-Primary Key) FirstName LastName HourlyWage ... (and any other field you might want for that employee)
EmployeeGroups -------------- EmployeeID (Number-Primary Key) SubGroupID (Number-Primary Key)
Sorry to disagree with you on this one: if an employee only belongs to a single sub-group you can (and you should) use a foreing key in the employee table to relate each record to a record on the subgroup table. Your option only makes sense if an employee can belong to several subgroups simultaneously.
|
 |
|
Nikkol
Forum Moderator
    
USA
6907 Posts |
Posted - 19 February 2002 : 21:19:29
|
quote:
Sorry to disagree with you on this one: if an employee only belongs to a single sub-group you can (and you should) use a foreing key in the employee table to relate each record to a record on the subgroup table. Your option only makes sense if an employee can belong to several subgroups simultaneously.
Yes, I know. I assumed that an employee belonged to more than one subgroup since snaayk structure his activity table with a group number as well as employee id. If an employee only belonged to one subgroup, then there would be no need for the group number in the activity table.
Nikkol |
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 19 February 2002 : 21:25:07
|
quote:
So, 12,000 records a month isn't all that much (considering the size of the data)? That's good to know.
A quick estimatee for the size of your daily recors table is between 25 and 30 bytes. 12000 of them makes 360000 bytes a month, that is, around 352K a month for the daily records. You can use your DB for several years without a problem .
quote:
I guess I would then begin using inner joins for some of the queries that pull data from the multiple tables? Like total OT for all the group?
Every query that needs to use data for more than one table will need inner joins. But use Access QBE and it will be automatically done for you, as long as you define relationships for your tables previously...
Edited by - ruirib on 19 February 2002 21:27:51 |
 |
|
snaayk
Senior Member
   
USA
1061 Posts |
Posted - 19 February 2002 : 23:57:51
|
If I understand this right, I should create the individual tables - group, subgroup,employee,dailyactivity, which makes sense (2020 hindsight).
I then create relationships between the tables using the foreing keys, such as:
Group Table GroupID (number-Primary Key) GroupName any other info
SubGroup Table SubGroupID (number-Primary Key) GroupID (Foreign Key with Group Table "GroupID") Additional Info
Employee Table EmployeeID (Number-Primary Key) SubGroupID (Foriegn Key with SubGroup Table "SubGroupID")
DailyActivity Table ID (Autonumber-Primary Key) EmployeeID (Foriegn Key with Employee Table "EmployeeID") All the extra info
quote: But use Access QBE and it will be automatically done for you, as long as you define relationships for your tables previously...
I looking for my copy of access to start this up and see exactly what you mean. But what will be done automatically for me? I still need to do the joins on my where clauses, no? such as:
OT FOR A SUBGROUP:
SELECT TABLE_DAILYACTIVITY.OT, TABLE_SUBGROUP.NAME FROM TABLE_EMPLOYEE INNER JOIN TABLE_SUBGROUP ON TABLE_EMPLOYEE.SUBGROUPID = TABLE_SUBGROUP.SUBGROUPID WHERE SUBGROUPID = 3
Also, if I wanted to do it for the group, do I inner join again on the GROUPID?
I know I'm asking a lot, but I really appreciate it!
|
 |
|
Nikkol
Forum Moderator
    
USA
6907 Posts |
Posted - 20 February 2002 : 00:27:01
|
Your SQL statement will depend on the OT you are actually looking for. Is it for one employee? Is it the sum of all OT in a subgroup for only one day? It all depends on what you want.
For instance, the OT for all employees in a subgroup for one particular day would be something like:
SELECT tblSubGroups.EmployeeID, tblActivity.OT FROM tblSubGroups, tblActivity WHERE tblSubGroups.SubGroupID = 3 AND tblActivity.ActivityDate = #2/19/02# AND tblSubGroups.EmployeeID = tblActivity.EmployeeID
Your result is a recordset with a record for the overtime of each employee for that date and subgroup.
I didn't use INNER JOIN, but the WHERE part implies an inner join (I think). Also, # is used if your date field is set as a date type in Access.
Have you checked out the articles in http://www.4guysfromrolla.com? It's a great site for learning ASP and database integration.
Nikkol |
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 20 February 2002 : 05:02:01
|
quote:
I then create relationships between the tables using the foreing keys, such as:
Group Table GroupID (number-Primary Key) GroupName any other info
SubGroup Table SubGroupID (number-Primary Key) GroupID (Foreign Key with Group Table "GroupID") Additional Info
Employee Table EmployeeID (Number-Primary Key) SubGroupID (Foriegn Key with SubGroup Table "SubGroupID")
DailyActivity Table ID (Autonumber-Primary Key) EmployeeID (Foriegn Key with Employee Table "EmployeeID") All the extra info
quote: But use Access QBE and it will be automatically done for you, as long as you define relationships for your tables previously...
I looking for my copy of access to start this up and see exactly what you mean. But what will be done automatically for me? I still need to do the joins on my where clauses, no? such as:
In Access in fact you establish relationships by using the relationships window. That's where you tell Access that, for example, GroupID in group table has a 1 to many relationship with GroupID in subgroup table. To do this you just add both tables to the relationship window and then just drag the GroupID column from the group table over to the GroupID column in the subgroup table. Access will open a dialog window where it will tell that you are creating a relationship (1 to many) and you'll have check boxes to choose Enforce Referential Integrity (you should select this one), cascade update related fields (probably should select this one) and cascade delete related fields (I usually leave this one clear in order to avoid undesired "undirect" deletes).
DO this for all the tables and fields where you have foreign keys.
Then, when you create a query, using the QBE, you just need to add the desired tables to the query and Access will automatically create the joins clauses for you. You just need to select the columns you want in the lower area of the QBE window...
quote:
OT FOR A SUBGROUP:
SELECT TABLE_DAILYACTIVITY.OT, TABLE_SUBGROUP.NAME FROM TABLE_EMPLOYEE INNER JOIN TABLE_SUBGROUP ON TABLE_EMPLOYEE.SUBGROUPID = TABLE_SUBGROUP.SUBGROUPID WHERE SUBGROUPID = 3
Also, if I wanted to do it for the group, do I inner join again on the GROUPID?
There is something missing in this query, something that is not missing in Nichols posterior post, and that is the join between the employee and subgroup tables. The easiest way to do this, if you are not quite that easy with SQL (or even if you are I do this all the time as it is easier ), would be to create a new query, add the tables Employee, DailyActivity and Subgroup tables to the query. Then drag the desired fields to the bottom part of the QBE: OT and Date from DaylyActivity, Name from SubGroup. If you wanted them you could add conditions to fields (for example if you wanted to know the OT for subgroup 3, you dragg ID field from subgroup table to the bottom part of the QBE and then just write 3 in the criteria field for that column; you probably want to add a criteria for date field in order to specify a given date or date interval).
See that in all of my previous explanation I never mentioned SQL, because Access will create it automatically for you, including the join clauses. This would happen obviouslly if you previously created the relationships between tables as I explained in the first part of my message. It's a one time task and it will save you a lot of work when creating queries using the QBE.
Hope this helps a bit...
Edited by - ruirib on 20 February 2002 05:07:39 |
 |
|
snaayk
Senior Member
   
USA
1061 Posts |
Posted - 20 February 2002 : 06:45:59
|
can you use queries from the QBE in an ASP web page? Or is this using access as the form and interface?
|
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 20 February 2002 : 06:55:25
|
quote:
can you use queries from the QBE in an ASP web page? Or is this using access as the form and interface?
Yes. Just choose SQL View for the query, copy the SQL code and paste it in the ASP.
You could also save the query and execute it from the ASP, eventually providing the needed parameters. It's quite simple to do it.
|
 |
|
snaayk
Senior Member
   
USA
1061 Posts |
Posted - 20 February 2002 : 09:29:38
|
Thats Great!!! I got to work and started messing with access. That QBE SQL view is awesome! I didn't know that was there. I did like you said, created the relationships, made the queries and saw the SQL created, which I can just copy and modify to take values from the querystring or what have you. Thanks, I think this will work great! Not to mention it makes understanding the inner-joins a lot easier. Especially for the more complex queries.
Any ideas on the best way to add the records? every subgroup will add 15 records daily, at the same time. Whats the best way to do it one after the other. I was hoping there might be a way to make a form that would add 15 records at a time. BUt I can't seem to find anything on the ASP sites. Nikkol, you had an idea here? 
|
 |
|
Nikkol
Forum Moderator
    
USA
6907 Posts |
Posted - 20 February 2002 : 10:00:00
|
Yeah, I was thinking about it. You COULD make create a form that displays textboxes for the fields needing values for each employee in a subgroup. Something like:
Employee1 Box1 Box2 Box3 Employee2 Box1 Box2 Box3 ...
where the name of the textboxes are the same for a particular field. That way, when you post the form, the values for the set of textboxes with the same name can be retrieved as an array. That seems messy though.
Another option would be to create the same page with a form for each employee, where you post back to the same page, update the data and can continue. That seems messy too.
I'd like to hear other's thoughts on how to do this as well.
Nikkol |
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 20 February 2002 : 10:04:40
|
quote:
Thats Great!!! I got to work and started messing with access. That QBE SQL view is awesome! I didn't know that was there. I did like you said, created the relationships, made the queries and saw the SQL created, which I can just copy and modify to take values from the querystring or what have you. Thanks, I think this will work great! Not to mention it makes understanding the inner-joins a lot easier. Especially for the more complex queries.
Glad you like it . I think the QBE is a good SQL learning tool.
quote:
Any ideas on the best way to add the records? every subgroup will add 15 records daily, at the same time. Whats the best way to do it one after the other. I was hoping there might be a way to make a form that would add 15 records at a time. But I can't seem to find anything on the ASP sites. Nikkol, you had an idea here?
I think you can probably create an ASP page with enough controls to acommodate input for all workers in a subgroup, get the data for them from a given user, allow you to verify that all is correct and invoke an action script to write all the data on the database. You could try to coordinate the action of this script from a higher level script that would invoke it with the subgroup as a parameter and would loop through all the subgroups.
Allow me a question: does it have to be done in ASP? An Access form, with VBA programming, would provide greater control and added flexibility in doing this. Obviously if you'll have several people doing this an ASP solution becomes more atractive. But the coordination between the successive intervening scripts is more complex. Of course you could also have a single script doing this, but that will make it even more a complex script.
Tell me what you think...
Edited by - ruirib on 20 February 2002 10:08:43 |
 |
|
snaayk
Senior Member
   
USA
1061 Posts |
Posted - 20 February 2002 : 15:40:33
|
quote:
Allow me a question: does it have to be done in ASP? An Access form, with VBA programming, would provide greater control and added flexibility in doing this. Obviously if you'll have several people doing this an ASP solution becomes more atractive. But the coordination between the successive intervening scripts is more complex. Of course you could also have a single script doing this, but that will make it even more a complex script.
I think ASP would ideal. For one, I am a little familiar with ASP. How to add,display,delete,update the records; more so than VB. The other thing is I am hoping to have this on the intranet within an existing layout (design will have to match, not sure if it would make a difference) Lastly, a lot of users. In terms of records being added, one person per subgroup will add an average of 15 records daily. There are rougly 36 subgroups. These subgroups are divided into 4 or 5 groups. The groups will run queries on the individual employee (like a subgroup), a subgroup, a group or all/some groups.
Now, I like the idea of running an insert based on a subgroup. So if I say I want to add the data for subgroup 8. I could have one form that would have lets say 15 rows and each row could represent a record with the relevant fields going to the field in the db?
quote: Another option would be to create the same page with a form for each employee, where you post back to the same page, update the data and can continue. That seems messy too.
Thats what I was thinking. On a succesful insert, redirect to the same page. I was thinking perhaps pull every employee within a subgroup and after every success, redirect with a next employeeid in the querystring and use that for the where clause. But I dont know if this could be done and it sounds a little complicated and rough. Also, employee IDs will not be sequential in a given group.
|
 |
|
Topic  |
|
|
|