Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. ~
  2. /*
  3.  *  Knots are used to store finite sets of values, normally used to describe states
  4.  *  of entities (through knotted attributes) or relationships (through knotted ties).
  5.  *
  6.  */
  7. ~
  8. var knot;
  9. for(var k = 0; knot = schema.knot[schema.knots[k]]; k++) {
  10.     if(knot.metadata.generator == 'true')
  11.         knot.identityGenerator = 'IDENTITY(1,1)';
  12.     else
  13.         knot.identityGenerator = '';
  14.     if(schema.metadataUsage == 'true')
  15.         knot.metadataDefinition = knot.metadataColumnName + ' ' + schema.metadataType + ' not null,';
  16.     else
  17.         knot.metadataDefinition = '';
  18. ~
  19. ----------------------------------- [Knot Table] -------------------------------------
  20. -- $knot.name table (number ${(knot.position + 1)}$ of $schema.knots.length)
  21. --------------------------------------------------------------------------------------
  22. IF NOT EXISTS (SELECT * FROM sys.objects WHERE name = $knot.name and type LIKE '%U%')
  23. CREATE TABLE [$knot.capsule].[$knot.name] (
  24.     $knot.identityColumnName $knot.identity $knot.identityGenerator not null,
  25.     $knot.name $knot.dataRange not null,
  26.     $knot.metadataDefinition
  27.     constraint pk$knot.name primary key (
  28.         $knot.identityColumnName asc
  29.     ),
  30.     constraint uq$knot.name unique (
  31.         $knot.name
  32.     )
  33. );
  34. GO
  35. ~
  36. }