Best way to store multiple values from multiple daily transactions





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I'm currently developing a Timeclock web application which will store the date, hour, and minutes which a user logs into and out of the application via a MYSQL Database. Users can log into and out of the application multiple times per day, thus 1 user can have up to 6 transactions per day. What would be the best way to store multiple transactions such as above, in a database? I'm a web developer, and our Database Admin is currently gone for summer, so I apologize if this is a pretty easy question, but I'm confused on how to optimize the storing (and later retrieval) of multiple values in this instance.










share|improve this question














bumped to the homepage by Community 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















    0















    I'm currently developing a Timeclock web application which will store the date, hour, and minutes which a user logs into and out of the application via a MYSQL Database. Users can log into and out of the application multiple times per day, thus 1 user can have up to 6 transactions per day. What would be the best way to store multiple transactions such as above, in a database? I'm a web developer, and our Database Admin is currently gone for summer, so I apologize if this is a pretty easy question, but I'm confused on how to optimize the storing (and later retrieval) of multiple values in this instance.










    share|improve this question














    bumped to the homepage by Community 8 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0








      I'm currently developing a Timeclock web application which will store the date, hour, and minutes which a user logs into and out of the application via a MYSQL Database. Users can log into and out of the application multiple times per day, thus 1 user can have up to 6 transactions per day. What would be the best way to store multiple transactions such as above, in a database? I'm a web developer, and our Database Admin is currently gone for summer, so I apologize if this is a pretty easy question, but I'm confused on how to optimize the storing (and later retrieval) of multiple values in this instance.










      share|improve this question














      I'm currently developing a Timeclock web application which will store the date, hour, and minutes which a user logs into and out of the application via a MYSQL Database. Users can log into and out of the application multiple times per day, thus 1 user can have up to 6 transactions per day. What would be the best way to store multiple transactions such as above, in a database? I'm a web developer, and our Database Admin is currently gone for summer, so I apologize if this is a pretty easy question, but I'm confused on how to optimize the storing (and later retrieval) of multiple values in this instance.







      mysql






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 27 '17 at 20:48









      Justin E. SamuelsJustin E. Samuels

      1011




      1011





      bumped to the homepage by Community 8 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 8 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          2 Answers
          2






          active

          oldest

          votes


















          0














          I would normally expect that you'd have at least the following:



          User table: has user's login_id (probably literally the ID they use to login to the system), FullName, plus other user info (don't have enough info to know what else goes in here - department, job title, etc.). This is technically optional, but is helpful to tie logins to people's actual names.



          TimeEntry table: user's login_id, EntryTime (probably using the timestamp data type), EntryType ("I" for login, "O" for logout - this is optional, but helpful if it's possible for login or logout values to be missing (for instance, an involuntary logout due to a power failure)); plus, other relevant values (if any).



          The login_id makes sure the entries belong to the right user. The times give us the order in which things happened. As noted, the login/logout flag helps if an entry is missing for some reason. Not sure if this is being captured automatically or if it requires action on the user's part; missing entries much more likely with the latter. I'm assuming that, when populating the EntryTime column, you'll just use CURRENT_TIMESTAMP(); should provide maximum available time data, and help line up very rapid login/logouts if EntryType can't be set. (I've captured similar data from the database end on an MS SQL Server system, and the application would usually have one login that lasted for well under a second before actually connecting for real.)



          NOTE: If it's possible to have a login without a logout, EntryType will help you properly match the pairs you have. If you have 5 entries for a user on a given day (say, "8AM", "10AM", "1PM", "4PM", "5PM"), and no EntryType flag, you don't know whether the missing entry is a login or a logout, or where it falls; if that is available (["8AM", "I"]; ["10AM", "O"]; ["1PM", "O"]; ["4PM", "I"]; ["5PM", "O"]), then you can easily identify the unmatched entry, and have at least a minimum confirmed hours logged in (3 hours).



          AND: remember to allow for the possibility that login and logout aren't on the same calendar day (if applicable).






          share|improve this answer































            0














            What happens on the 7th session?



            I suggest you simply store all sessions. Later, when querying the table, you still have the info that someone was "doing too much work". And/or you can just list the 'first' 6.






            share|improve this answer
























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "182"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f172210%2fbest-way-to-store-multiple-values-from-multiple-daily-transactions%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              I would normally expect that you'd have at least the following:



              User table: has user's login_id (probably literally the ID they use to login to the system), FullName, plus other user info (don't have enough info to know what else goes in here - department, job title, etc.). This is technically optional, but is helpful to tie logins to people's actual names.



              TimeEntry table: user's login_id, EntryTime (probably using the timestamp data type), EntryType ("I" for login, "O" for logout - this is optional, but helpful if it's possible for login or logout values to be missing (for instance, an involuntary logout due to a power failure)); plus, other relevant values (if any).



              The login_id makes sure the entries belong to the right user. The times give us the order in which things happened. As noted, the login/logout flag helps if an entry is missing for some reason. Not sure if this is being captured automatically or if it requires action on the user's part; missing entries much more likely with the latter. I'm assuming that, when populating the EntryTime column, you'll just use CURRENT_TIMESTAMP(); should provide maximum available time data, and help line up very rapid login/logouts if EntryType can't be set. (I've captured similar data from the database end on an MS SQL Server system, and the application would usually have one login that lasted for well under a second before actually connecting for real.)



              NOTE: If it's possible to have a login without a logout, EntryType will help you properly match the pairs you have. If you have 5 entries for a user on a given day (say, "8AM", "10AM", "1PM", "4PM", "5PM"), and no EntryType flag, you don't know whether the missing entry is a login or a logout, or where it falls; if that is available (["8AM", "I"]; ["10AM", "O"]; ["1PM", "O"]; ["4PM", "I"]; ["5PM", "O"]), then you can easily identify the unmatched entry, and have at least a minimum confirmed hours logged in (3 hours).



              AND: remember to allow for the possibility that login and logout aren't on the same calendar day (if applicable).






              share|improve this answer




























                0














                I would normally expect that you'd have at least the following:



                User table: has user's login_id (probably literally the ID they use to login to the system), FullName, plus other user info (don't have enough info to know what else goes in here - department, job title, etc.). This is technically optional, but is helpful to tie logins to people's actual names.



                TimeEntry table: user's login_id, EntryTime (probably using the timestamp data type), EntryType ("I" for login, "O" for logout - this is optional, but helpful if it's possible for login or logout values to be missing (for instance, an involuntary logout due to a power failure)); plus, other relevant values (if any).



                The login_id makes sure the entries belong to the right user. The times give us the order in which things happened. As noted, the login/logout flag helps if an entry is missing for some reason. Not sure if this is being captured automatically or if it requires action on the user's part; missing entries much more likely with the latter. I'm assuming that, when populating the EntryTime column, you'll just use CURRENT_TIMESTAMP(); should provide maximum available time data, and help line up very rapid login/logouts if EntryType can't be set. (I've captured similar data from the database end on an MS SQL Server system, and the application would usually have one login that lasted for well under a second before actually connecting for real.)



                NOTE: If it's possible to have a login without a logout, EntryType will help you properly match the pairs you have. If you have 5 entries for a user on a given day (say, "8AM", "10AM", "1PM", "4PM", "5PM"), and no EntryType flag, you don't know whether the missing entry is a login or a logout, or where it falls; if that is available (["8AM", "I"]; ["10AM", "O"]; ["1PM", "O"]; ["4PM", "I"]; ["5PM", "O"]), then you can easily identify the unmatched entry, and have at least a minimum confirmed hours logged in (3 hours).



                AND: remember to allow for the possibility that login and logout aren't on the same calendar day (if applicable).






                share|improve this answer


























                  0












                  0








                  0







                  I would normally expect that you'd have at least the following:



                  User table: has user's login_id (probably literally the ID they use to login to the system), FullName, plus other user info (don't have enough info to know what else goes in here - department, job title, etc.). This is technically optional, but is helpful to tie logins to people's actual names.



                  TimeEntry table: user's login_id, EntryTime (probably using the timestamp data type), EntryType ("I" for login, "O" for logout - this is optional, but helpful if it's possible for login or logout values to be missing (for instance, an involuntary logout due to a power failure)); plus, other relevant values (if any).



                  The login_id makes sure the entries belong to the right user. The times give us the order in which things happened. As noted, the login/logout flag helps if an entry is missing for some reason. Not sure if this is being captured automatically or if it requires action on the user's part; missing entries much more likely with the latter. I'm assuming that, when populating the EntryTime column, you'll just use CURRENT_TIMESTAMP(); should provide maximum available time data, and help line up very rapid login/logouts if EntryType can't be set. (I've captured similar data from the database end on an MS SQL Server system, and the application would usually have one login that lasted for well under a second before actually connecting for real.)



                  NOTE: If it's possible to have a login without a logout, EntryType will help you properly match the pairs you have. If you have 5 entries for a user on a given day (say, "8AM", "10AM", "1PM", "4PM", "5PM"), and no EntryType flag, you don't know whether the missing entry is a login or a logout, or where it falls; if that is available (["8AM", "I"]; ["10AM", "O"]; ["1PM", "O"]; ["4PM", "I"]; ["5PM", "O"]), then you can easily identify the unmatched entry, and have at least a minimum confirmed hours logged in (3 hours).



                  AND: remember to allow for the possibility that login and logout aren't on the same calendar day (if applicable).






                  share|improve this answer













                  I would normally expect that you'd have at least the following:



                  User table: has user's login_id (probably literally the ID they use to login to the system), FullName, plus other user info (don't have enough info to know what else goes in here - department, job title, etc.). This is technically optional, but is helpful to tie logins to people's actual names.



                  TimeEntry table: user's login_id, EntryTime (probably using the timestamp data type), EntryType ("I" for login, "O" for logout - this is optional, but helpful if it's possible for login or logout values to be missing (for instance, an involuntary logout due to a power failure)); plus, other relevant values (if any).



                  The login_id makes sure the entries belong to the right user. The times give us the order in which things happened. As noted, the login/logout flag helps if an entry is missing for some reason. Not sure if this is being captured automatically or if it requires action on the user's part; missing entries much more likely with the latter. I'm assuming that, when populating the EntryTime column, you'll just use CURRENT_TIMESTAMP(); should provide maximum available time data, and help line up very rapid login/logouts if EntryType can't be set. (I've captured similar data from the database end on an MS SQL Server system, and the application would usually have one login that lasted for well under a second before actually connecting for real.)



                  NOTE: If it's possible to have a login without a logout, EntryType will help you properly match the pairs you have. If you have 5 entries for a user on a given day (say, "8AM", "10AM", "1PM", "4PM", "5PM"), and no EntryType flag, you don't know whether the missing entry is a login or a logout, or where it falls; if that is available (["8AM", "I"]; ["10AM", "O"]; ["1PM", "O"]; ["4PM", "I"]; ["5PM", "O"]), then you can easily identify the unmatched entry, and have at least a minimum confirmed hours logged in (3 hours).



                  AND: remember to allow for the possibility that login and logout aren't on the same calendar day (if applicable).







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Apr 27 '17 at 21:30









                  RDFozzRDFozz

                  9,90731631




                  9,90731631

























                      0














                      What happens on the 7th session?



                      I suggest you simply store all sessions. Later, when querying the table, you still have the info that someone was "doing too much work". And/or you can just list the 'first' 6.






                      share|improve this answer




























                        0














                        What happens on the 7th session?



                        I suggest you simply store all sessions. Later, when querying the table, you still have the info that someone was "doing too much work". And/or you can just list the 'first' 6.






                        share|improve this answer


























                          0












                          0








                          0







                          What happens on the 7th session?



                          I suggest you simply store all sessions. Later, when querying the table, you still have the info that someone was "doing too much work". And/or you can just list the 'first' 6.






                          share|improve this answer













                          What happens on the 7th session?



                          I suggest you simply store all sessions. Later, when querying the table, you still have the info that someone was "doing too much work". And/or you can just list the 'first' 6.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Apr 29 '17 at 19:35









                          Rick JamesRick James

                          43.9k22360




                          43.9k22360






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Database Administrators Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f172210%2fbest-way-to-store-multiple-values-from-multiple-daily-transactions%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Liste der Baudenkmale in Friedland (Mecklenburg)

                              Single-Malt-Whisky

                              Czorneboh