Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    New Coder
    Join Date
    Aug 2014
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Building a form to put to db - Advice

    I'm looking to build a form that has two distinct sections.

    Section 1 - 4 fields that are filled out once.
    Section 2 - 11 fields that are filled out as necessary. 4 of these are pulled from another database.

    My question is, would it be better to have the fields in Section 1 be a database and the fields in Section 2 fill in that database? And what would be the best way to go about that?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,561
    Thanks
    80
    Thanked 4,495 Times in 4,459 Posts
    First of all, *ONE* database. Period.

    You will likely then use multiple TABLES in that one database.

    If your section 2 can occur multiple times PER section 1, then of course you need (at least) 2 tables.

    If you really mean "4 of these are pulled from another database" then why are those fields "filled out"??? Do you mean that you will get the values from another database (or do you again mean TABLE when you say database?) and allow them to be changed and saved back to that other database/table?

    It would help if you would be a LOT more specific about what is going on.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New Coder
    Join Date
    Aug 2014
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts
    You are correct. One database, multiple tables. I worded it wrong, sorry.



    Here are the fields that would be filled out once per survey.

    Date of Survey
    Plant Name
    Plant Location
    Plant Contact Name

    The next section that would be filled out as needed would be

    Direction
    Location (detailed as possible)
    Floor Level
    Elevation (in feet)
    Tag Number
    Manufacturer - Called from another table.
    Model Number - Called from another table.
    Size - Called from another table.
    Pressure - Called from another table.
    Service
    Trap Conditions

    On submit, all the info in section 2 would be saved. Then when the survey is complete, the whole thing would be saved.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,561
    Thanks
    80
    Thanked 4,495 Times in 4,459 Posts
    Okay, a standard 2-table one-to-many relationship.

    Except I still don't get the fields called from another table: How do you know WHICH values to put there? What allows you to choose only one (or only some) records from that other table so that only they will appear in the <form>??

    Possible example: The user fills in the "Tag number" field and then you go ask the database for the info about that tag number and it comes back with Manufacturer, Model number, etc.
    If it's not "Tag number" that tells you what data to fetch, what is it?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,561
    Thanks
    80
    Thanked 4,495 Times in 4,459 Posts
    On submit, all the info in section 2 would be saved. Then when the survey is complete, the whole thing would be saved
    You really can't do that. You need to create the record for the info in the top part FIRST, so that you can get its ID and use that id to link to the multiple second parts.

    Now, you COULD mark a survey (first part) as "incomplete" and then only change it to "complete" when the user enters the last section 2. That's easy.

    And then, maybe once a week or so, you could go and delete all incomplete surveys.

    Notice that this has a second nice effect: If the user loses connection the server (or just goes home for the night), when he reconnects he can call up that incomplete survey and continue entering section 2's until it is complete.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    New Coder
    Join Date
    Aug 2014
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    Except I still don't get the fields called from another table: How do you know WHICH values to put there? What allows you to choose only one (or only some) records from that other table so that only they will appear in the <form>??
    These fields are pulled from a database table that has all the manufacturers, models, sizes, and pressures already put in.

  • #7
    New Coder
    Join Date
    Aug 2014
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    You really can't do that. You need to create the record for the info in the top part FIRST, so that you can get its ID and use that id to link to the multiple second parts.

    Now, you COULD mark a survey (first part) as "incomplete" and then only change it to "complete" when the user enters the last section 2. That's easy.

    And then, maybe once a week or so, you could go and delete all incomplete surveys.

    Notice that this has a second nice effect: If the user loses connection the server (or just goes home for the night), when he reconnects he can call up that incomplete survey and continue entering section 2's until it is complete.
    This is fine. I'm not sure how to accomplish this.

    Also, I have to add a Tested Date to the section 2 part. To denote the exact date of testing. Some of these surveys can last 12 weeks.

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,561
    Thanks
    80
    Thanked 4,495 Times in 4,459 Posts
    Quote Originally Posted by bobbyshirley View Post
    These fields are pulled from a database table that has all the manufacturers, models, sizes, and pressures already put in.
    Yes, but how can the code no *WHICH* data to pull??? Which manufacture with which model? etc.

    I asked you if the "tag number" was how that data was looked up. You didn't reply, at all.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #9
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,561
    Thanks
    80
    Thanked 4,495 Times in 4,459 Posts
    Quote Originally Posted by bobbyshirley View Post
    This is fine. I'm not sure how to accomplish this.
    Then are you the right person to do this job? If it is critical to the company, why have they assigned a neophyte to do it?

    Also, I have to add a Tested Date to the section 2 part. To denote the exact date of testing. Some of these surveys can last 12 weeks.
    Ummm...then what is the purpose of the "Date of survey" in section 1?

    And if a section 1 survey can last 12 weeks, all the more reason to do as I suggested and add a complete/incomplete flag to the table.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #10
    New Coder
    Join Date
    Aug 2014
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    Yes, but how can the code no *WHICH* data to pull??? Which manufacture with which model? etc.

    I asked you if the "tag number" was how that data was looked up. You didn't reply, at all.
    Sorry, no this form is for input. Tag number is put in from the surveyor. After that Manufacturer is a dropdown (from table), once that is selected, Model is available, once model is selected then Size is available, once size is selected then pressure.

  • #11
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,561
    Thanks
    80
    Thanked 4,495 Times in 4,459 Posts
    Ahhh...helps tremendously when you say all that.

    What is the TOTAL NUMBER of possible Manufacturer/Model/Size selections?

    Probably, that's the same as the total number of records in that external table.

    Is that external table in the same database? Or at least on the same server?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #12
    New Coder
    Join Date
    Aug 2014
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    Then are you the right person to do this job? If it is critical to the company, why have they assigned a neophyte to do it?


    Ummm...then what is the purpose of the "Date of survey" in section 1?

    And if a section 1 survey can last 12 weeks, all the more reason to do as I suggested and add a complete/incomplete flag to the table.
    The date of survey in section 1 would be the unique identifier. I agree the complete/incomplete is a great addition to the table.

    Am I the right person for the job? They have hired me. My job is to figure this out and build it, which is why I'm here asking for input. I can get the job done, just looking for input and thoughts from others who have more experience.

  • #13
    New Coder
    Join Date
    Aug 2014
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    Ahhh...helps tremendously when you say all that.

    What is the TOTAL NUMBER of possible Manufacturer/Model/Size selections?

    Probably, that's the same as the total number of records in that external table.

    Is that external table in the same database? Or at least on the same server?
    16+ total manufacturers. Yes, it's in a external table on the same server.

    But the tags in a survey could be in the tens of thousands depending on the plant and length of survey.

  • #14
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,561
    Thanks
    80
    Thanked 4,495 Times in 4,459 Posts
    Read carefully what I asked, again:
    What is the TOTAL NUMBER of possible Manufacturer/Model/Size selections?
    16 manufacturers, okay. But say each had 1000 models and each model had 20 sizes. That's a total of 320,000 combinations. That is the number I'm looking for. The reason: To determine whether or not we need to use AJAX to get the data for the dropdowns (or not...simpler if not, but then I'd want no more than about 1000 combinations).
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #15
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,561
    Thanks
    80
    Thanked 4,495 Times in 4,459 Posts
    Quote Originally Posted by bobbyshirley View Post
    But the tags in a survey could be in the tens of thousands depending on the plant and length of survey.
    Would not be a problem for MySQL (except for disk space, maybe) if the number of surveys and/or section 2's was in the BILLIONS.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  
    Page 1 of 2 12 LastLast

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •