Welcome Guest, Not a member yet? Register   Sign In
need help for cloning concatenated Data from DB
#1

I have a big problem in anew project that is about to be launched in a few days

Data is concatenated and i find no better way to clone it

================
DB Structure :
One Course has many chapters ,
Every Chapter has many Subjects ,
Every Subject has many Questions ,
Every Question has many Answers .
================================
Required cloning a course from user to another

================================
I did it like that :
================
1- select query = course
insert query = new course -> new course ID

    2- select query = chapters of course
      loop start on chapters
        using new course ID :
        insert query = new chapter -> new chapter ID

          3- select query = subjects of chapter
            loop start on subjects
              using new chapter ID :
              insert query = new subject -> new subject ID

              4- select query = questions of subject
                loop start on Questions
                  using new subject ID :
                  insert query = new question -> new question ID

                    5- and so on for answers

                loop end on Questions

            loop end on subjects

      loop end on Chapters

================================
The problem is that a single course could have a 400 questions
and this leads to a massive no of queries 1000+ to be done specially when this process is done repeatedly
================================
waiting for your generous help
Reply


Messages In This Thread
need help for cloning concatenated Data from DB - by khashabawy - 02-09-2016, 09:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB