9 Replies Latest reply: Jan 16, 2013 4:32 PM by Marina Alvarez Ruiz RSS

    How manage an auto-refers inside QV

      Hi.

      I need to know how QV manages an auto-refers.

      F.e. I could read a Personnel or Employees table with EmployeeCode as PK and ManagerCode as FK linked to the same table. I know that in QV a relation is stablished by maintaning the same name between fields to link. But in this case, I have a DUMP for the load script and I must use two different names, EmployeeCode and ManagerCode.

      How can I solve this issue, please? Thanks

      I'm using QV 10 SR1.

        • AW:How manage an auto-refers inside QV
          Martina Brenner

          Hi,

          thats easy, load the fields again and rename them, something like:

          Load EmployeeCode As %EmployeeKey,
          EmployeeCode,
          ....
          From Table1;

          Load ManagerCode As %EmployeeKey,
          ManagerCode,
          ....
          From Table2;

           

            • AW:How manage an auto-refers inside QV

              Sorry, but I don't understand!

              Why Table1 and Table2? I have only the Personnel (or Employees) table with (f.e.) the following field:

              1. EmployeeCode

              2. FirstName

              3. LastName

              4. ManagerCode

              A Manager also belongs to the Personnel (or Employees) table. Into the underlying db, it exist an auto-reference for the Personnel table.

            • How manage an auto-refers inside QV

               

              I think you have to split information on twpo distinct tables, one for employees, and the other just for managers, try something like that :

              employee:
              load EmployeeCode, ManagerCode, otherInfo... from where you want

              manager:
              load Distinct ManagerCode resident employee;
              left join load EmployeeCode as ManagerCode, otherInfo as managerOtherInfo resident employee;

                • How manage an auto-refers inside QV

                  Hi, I'm a beginner with QV. Do you think or are you sure?

                  This case occurs frequently. Is there a best practice to manage it?

                  Moreover, for now, I'm using the statement SQL and the statement STORE to create the QVD files and then, in a QVW document, I will use the LOAD statement.

                  Many thanks

                    • How manage an auto-refers inside QV
                      John Witherspoon

                       


                      pscorca69 wrote: Hi, I'm a beginner with QV. Do you think or are you sure?
                      This case occurs frequently. Is there a best practice to manage it?




                      Separating managers and employees into two different tables is one option. However, out in the real world with real organization hierarchies, I'm guessing that won't tie your data together the way you want.

                      You could probably use a hierarchy load on the data. I haven't used hierarchy loads outside of a few test cases, but it could probably be used to store an organization hierarchy.

                      You could use a semantic load on the data. Everyone would be stored as employees, and you'd also store the relationship between employees, such as the manager->managed relationship. You can then navigate through the "hierarchy" by following these semantic links up and down.

                      I'm sure there are other options as well. Best practice depends on your exact requirements.