Logic Sample Database

The Logic Sample database is used in the reactive logic tutorial and illustrates advanced rules and database concepts. It is small and familiar but with sufficiently complex structures so that you can use it to explore several interesting use cases. This is a complex example: a recursive deep copy, using reactive logic. You can load this API sample into your installation.

For more information:

The following image illustrates the Logic Sample database: (Click the image to open it in a new window.)

Relationship Examples

The Logic Sample database illustrates classic examples of the kinds of parent/child relationships present in virtually all databases.

The following is a list of the key patterns:

One to Many

See the relationship between Customer (Parent) and Orders (Child).

One to Many Self Relationship

See the self-relationship from Departments to itself.

Many to Many Self Relationship

The product_billofmaterials table represents that:
  • A "kit" product may have many "component" products. For example, a wing can consist of engines and bolts.
  • A "component" product may be a component of many kits. For example, bolts are used in wings and engines.
Note: A product, such as a wing, can be a component (of a plane) and a kit.

The Logic Sample database contains the following products:

Consider the following example:
  • A Boing 747 consists of a Fuselage, Wing, and Bolts 
  • A Wing consists of an Engine and Bolts
That is represented by rows in the product_billofmaterials table, as follows:

Products are entered into the same products table but are differentiated, as follows:

  • Kit: A product with components. For example, Boing, Wing.
  • Component: A product that is a component. For example, Fuselage, Bolt, Wing, Engine.
Note: Wing is a kit and a component, a recursive relationship.

The following are relationships from product to product_billofmaterials:

  • inKits: product implemented by foreign key product_name, so:
    • product.inKits returns the product_billofmaterials identifying the kits in which a product is a member. So, bolt.inKits returns ( (Boing, Bolt) and (Wing, Bolt) )
    • product_billofMaterials.product returns the component. So, (Boing, Bolt) returns Bolt

  • components: kit implemented by foreign key product_name_kit, so:
    • product.components returns the product_billofmaterials identifying the components in this kit. So, boing.components returns ( (Boing, Bolt) (Boing, Fuselage) (Boing, Wing) )
    • ProductBillofmaterials.kit returns the kit. So, (Boing, Bolt) returns Boing.

A Boing price calculates to $10,300:

  • 1 Fuselage @ $1300 = $1,300
  • 100 Bolts @ $10 = $1,000
  • 2 Wings @ $4,000 = $8,000, which itself is calculated as...
    • 2 Engines @ $1,500 = $3,000
    • 100 Bolts @ $10 = $1,000
Ordering a Boing 747 effects Product qtyOnHand, as follows:
  • totalQtyOrdered[Engines] increased by 4 (2 for each of 2 wings).
  • totalQtyOrdered[Bolts] increased by 300 (100 from Boing, 100 for each of 2 wings).
Ordering the Boing 747 inserts the following LineItems:
  • Boing 747
    • Bolts
    • Wing
      • Bolts
      • Engine
    • Fuselage

More Information

For more information about relationship examples, including details about the key patterns, see Relationship Examples.