Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Application Development » 2 Grandparents, 2 Parents and 1 Child table (How best to copy data from multiple parent tables to a child table)
2 Grandparents, 2 Parents and 1 Child table [message #3812] Wed, 31 July 2013 10:35 Go to next message
haider.faraz is currently offline  haider.faraz
Messages: 15
Registered: July 2013
Junior Member
The tables:
1 child table: courses
2 grandparent tables: planofstudies, templatecourses → create 1 parent table: planofstudycourses
2nd parent table: academicsessions

The schema of the tables is attached.

I want to create a record in the courses table. But I want to do that as follows:
  1. I want to start with a screen that lists academicsession records (AcademicSession: LIST1)
  2. I want to place a navigation button that reads "Manage Courses" that lists courses associated with the academicsession (Courses: LIST2)
  3. On the screen from step (b) I want to place a button that reads "Add Course" that lists all records from the planofstudycourses table along with extra fields fetched from the corresponding records from the planofstudies table and the templatecourses table (Planofstudycourses: LIST1)
  4. I want to place a navigation button on the screen from step (c) that reads "Add Course". When this button is pressed I want to:
  • Present a record from the courses table on the screen with data populated from the academicsession table from screen (a), planofstudies table and templatecourses table via the link table planofstudycourses from screen (c).
  • I then want to enter data for the fields course_class_and_section and teacherid via a textbox
  • On pressing the submit button I want to return to the screen in step (b).

I got as far as step (c) but I don't know how to complete step (d). How would you advice?
  • Attachment: schema.pdf
    (Size: 21.83KB, Downloaded 1209 times)
CORRECTION: 2 Grandparents, 2 Parents and 1 Child table [message #3813 is a reply to message #3812] Thu, 01 August 2013 00:05 Go to previous messageGo to next message
haider.faraz is currently offline  haider.faraz
Messages: 15
Registered: July 2013
Junior Member
The planofstudycourses table is not a parent table to the courses table. It is simply another table from which data is to be copied into the courses table.
UPDATE: 2 Grandparents, 2 Parents and 1 Child table [message #3814 is a reply to message #3813] Fri, 02 August 2013 05:38 Go to previous message
haider.faraz is currently offline  haider.faraz
Messages: 15
Registered: July 2013
Junior Member
I have solved this problem as follows:

  1. I made the planofstudycourses table a parent to the courses table
  2. I added the field 'planofstudycoursesID' to the courses table to relate it to the parent planofstudycourses table
  3. I made the screen in step (b) a MULTI 2 screen
  4. I made the courses table a link table between the academicsession table (outer table) and the planofstudycourses table (inner table)
  5. I removed fields from the courses table that were already present in the templatecourses table other than the instance specific fields 'course_title', 'course_class_and_section'
  6. I made the 'course_class_and_section' field non-mandatory in the courses table
  7. I copied the value of 'course_title' from the corresponding field in the templatecourses table

I also added the following function in the courses.class.inc file:
function _cm_getInitialData ($rowdata)
{
require_once 'classes/planofstudycourses.class.inc';
$dbobject =& RDCsingleton::getInstance('planofstudycourses');
$dbobject->sql_select = 'templateCourseID';
$foreign_data = $dbobject->getData("id='{$rowdata['id']}'");
$templateCourseID = $foreign_data[0]['templatecourseid'];

require_once 'classes/templatecourses.class.inc';
$dbobject2 =& RDCsingleton::getInstance('templatecourses');
$dbobject2->sql_select = 'templatecourse_title as course_title';
$foreign_data2 = $dbobject2->getData("id='{$templateCourseID}'");
$rowdata['course_title'] = $foreign_data2[0]['course_title'];

$count = $this->getCount("SELECT max(id) FROM $this->tablename");

$rowdata['planofstudycoursesid'] = $rowdata['id'];
$rowdata['id'] = $count + 1;

return $rowdata;
}
Previous Topic: Button on a detail record of a list transaction pattern
Next Topic: New window for graphics
Goto Forum:
  


Current Time: Wed Nov 27 06:14:52 EST 2024

Total time taken to generate the page: 0.01077 seconds