Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Flatten two tables to one

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Flatten two tables to one

    I have a "Student" table with student number, last and first name. I also have a "Grades" tables student number, course number and score. I have made a set with Students=>Grades where a student will have several grades in a 1 to many relation. This works fine.

    I need to create a new table that has just one flattened record per student with all the scores as part of the same record.

    Eg.

    Student # Last First Course1 Score1 Course 2 Score 2 Course 3 Score 3 etc...

    The number of courses will vary for each student.

    Any ideas how to do this?

    Thanks
    David Theoharides
    Assistant Superintendent of Schools
    Sanford School Department
    917 Main Street - Suite 200
    Sanford, ME 04073
    [email protected]

    #2
    Re: Flatten two tables to one

    You can get something close by creating a cross tab of the grades table.

    Group rows by student number, group columns by course, choose the grade field as the summarization and specify any of the choices (first, last, max) that you want.

    Then create a set with student as the parent and this result table as the child with a 1-1 relationship.
    There can be only one.

    Comment


      #3
      Re: Flatten two tables to one

      Thanks Stan... That sort of works, except that now every student's record has all the course numbers listed - not just their courses. The other courses all have a value of zero which will complicate my next step.

      Ideally I would like to only have courses listed that have scores.

      I even thought of exporting to excel and then trying to convert records with the same ID # to one record with multiple columns for each course and score.
      David Theoharides
      Assistant Superintendent of Schools
      Sanford School Department
      917 Main Street - Suite 200
      Sanford, ME 04073
      [email protected]

      Comment


        #4
        Re: Flatten two tables to one

        David, a problem with building a single table that will "fit" all students is that each student may have a different number of courses.

        Tell us more about why you need this table?

        I'm wondering if a memo field would work. It occurs to me that you could add a memo field to your Student's table, or link a new table containing only student_id and memo field (better choice). You could then use a script to step through the Grades table, passing courses and scores back to the student's memo field.

        Comment


          #5
          Re: Flatten two tables to one

          Maybe this is the wrong way to do it!

          I am still working on a way to calculate honor roll for students. On a FORM I can create several calculated fields that will indicate if the stduents has made honor roll level 1, 2 or 3. These are just calculated fields. Is there a way to use the calculated fields to update a field in the parent - eg. the calculated field would update a parent field called honor roll level and fill in 1, 2 or 3.

          The calculations required by our high school are:
          Level 1 - ALL grades above 93
          Level 2 - An average of 87 or above with no grades below 85
          Level 3 - An average of 85 or above allowing only 1 grade between 77 and 84

          I can generate a report that will produce the list of students, but ideally I would like to be able to FLAG or indicate (and become part of the parent) which level the student made for honeor roll.

          Thanks
          David Theoharides
          Assistant Superintendent of Schools
          Sanford School Department
          917 Main Street - Suite 200
          Sanford, ME 04073
          [email protected]

          Comment


            #6
            Re: Flatten two tables to one

            Sorry. Not enough detail for me to understand the difficulty.

            Perhaps the expressions you use in the calc fields could be used in a saved update operation that could be run against the Students table, after you've added an honor roll field to hold 0, 1, 2, or 3.

            Comment


              #7
              Re: Flatten two tables to one

              Due to the complexity of the honor roll rules, I would likely have to do several updates, unless there is a way to combine all the calculated fields into one.

              Thanks
              David Theoharides
              Assistant Superintendent of Schools
              Sanford School Department
              917 Main Street - Suite 200
              Sanford, ME 04073
              [email protected]

              Comment


                #8
                Re: Flatten two tables to one

                David, maybe it's time to write a custom script that does it in one pass through the Students table. In pseudo code it would look something like this:

                Code:
                1) open both tables, set indexes in each table based on student_id
                2) loop through the students table and for each student...
                    - set a counter to 1
                    - set cumulative score to 0
                    - find the first grade
                    - loop through grades until the student_id changes or eof() encountered
                      --- on each fetch increment the counter and sum the cumulative score
                    - when all grades are processed, divide cumulative score by the counter
                       to get the average score
                    - assign an honor roll score (0,1,2,3) to the student
                3) close both tables
                Obviously, this simple example computes only averages. However it could be easily modified to set flags or keep track of other data required by your honor roll criteria.
                Last edited by Tom Cone Jr; 01-06-2009, 03:08 PM.

                Comment


                  #9
                  Re: Flatten two tables to one

                  If you have a report that already gives you the correct honors rating, you could use the report events to write the rating to the student record.You wouldn't need a set to do this , a report with the course mark records grouped by the student_id would be all that is necessary.Lin the section events there will be an event for the student id group.I assume that would be where the rating would be shown.A simple xbasic script could open that record and write your calculated rating to a field on the student record: something like tb1.honor rating = calc-> student rating

                  Comment


                    #10
                    Re: Flatten two tables to one

                    Thanks for the response. I will give that a try also.

                    Tom Cone wrote a fantastic script for me last night (and tweaked it at 5 this morning) that will actually calculates each of the HR levels and then inserts the correct value in the parent table. It works GREAT!

                    I appreciate all the help from all A5 users. Your help has allowed me to use A5 to calculate the honor rolls for over 1300 students in seconds. It used to take us several days of manually crunching numbers to get this done.

                    Regards to all,

                    Dave
                    David Theoharides
                    Assistant Superintendent of Schools
                    Sanford School Department
                    917 Main Street - Suite 200
                    Sanford, ME 04073
                    [email protected]

                    Comment

                    Working...
                    X