Parent Child Table (part1)

Before I continue on with the Parent-Child Table Data-layer Structure or Object, I want mention that I know this is a LOT of code being thrown at you. And, I suspect that a few of you are saying "Yea..Yea. I can get this done with way less code!"  You may be right, you might be able to, but please stay with me to the end. Because I have a Suprise for you. The important thing about what I am showing you, is that you understand what I am showing you. You understand how things fit together, and how it works, and why.

So, lets proceed.  The Parent Child relationship.  It is one of the most common data-layer paradigms, if not THE most common. And honestly Thes structure can be Enormous.  When you factor in fickle users playing with a large structure, and then hitting "Cancel", such that all they have changed is undone, or NOT saved, can bring fear into the mind of any developer.

Starting off we will focus in on the Child. The reason for this is that the Child Record is almost Identical to the Single Stand-Alone Table. It has ALL the same procedures; I believe the biggest difference is a single Table Field.  This Table Field being the Foreign Key to its Parent Table.  Let's look at the example table structures.

As the Parent I'll select the Galaxy Structure, and as the Child, I'll select the SolarSystem Structure. This selection makes clear sense, every Galaxy has one or Many SolarSystems.


So, our Galaxy has: 
  • ID Primary Key, 
  • Name - VarChar(100)

SolarSystqm Table has 
  • ID Primary Key
  • GalaxyID - foreignKey link back to Galaxy\ID
  • Name - VarChar(100)
  • GRow - Integer The Galaxy Row Coordinante
  • GColumn - Integer The Galaxy Column Coordinate

The only meaningful difference from our Single Stand-alone table is the GalaxID Foreign Key. I can still see the Need for all the Procedures:

  • LoadComboBoxName()
  • LoadListViewName()
  • Find()
  • FindByName()
  • Save()
  • Delete()
  • DeleteValidate()
  • Validate()

So, now we will focus in on the rather significant additions and changes needed for the Parent Structure or Object.


Comments

Popular posts from this blog

How to build this without writing Code

Connecting the Forms to the Data-Layer (part 9)

Connecting the Forms to the Data-Layer (part 8)