Examples

In documentation for syntax element current

You can click on keywords and concepts in blue.
handdatabase X
{
  version 1.0 : initialized
  {
  }
  
  // this is the current version
  current version 2.0 : 1.0
  {
  }
  
  // this version is in-work
  version 2.1 : 2.0
  {
  }
}

In documentation for syntax element namespace

You can click on keywords and concepts in blue.
handnamespace My.Name.Space
{
  // Generates as My.Name.Space.Foo from client perspective
  database Foo
  {
  }
}

In documentation for syntax element integer

You can click on keywords and concepts in blue.
handtypes int as integer;

In documentation for syntax element real

You can click on keywords and concepts in blue.
handtypes number as real;
//...
column SomeColumn with DataType = type(number(10, 2));

In documentation for syntax element datetime

You can click on keywords and concepts in blue.
handtypes dt as datetime;
//...
column SomeColumn with DataType = type(dt);

In documentation for syntax element string

You can click on keywords and concepts in blue.
handtypes
  nstring ("nvarchar") as string,
  fixstring ("char") as string,
  guid ("uniqueidentifier") as string;
//...
column ID with DataType = type(guid);
column Column1 with DataType = type(nstring(200));
column USState with DataType = type(fixstring(2));

In documentation for syntax element as

You can click on keywords and concepts in blue.
handtypes int as integer;

In documentation for syntax element binding

You can click on keywords and concepts in blue.
handdesign
{
  view Foo ("tblFoo") with X = 5;
}
construction
{
  step sql
  {
SELECT TOP $[Foo.X] * FROM $[Foo]
  }
}

In documentation for syntax element hash

You can click on keywords and concepts in blue.
handdatabase TheDB
{
  version 1.0
  {
    hash 1091851333;
  }
}

In documentation for syntax element types

You can click on keywords and concepts in blue.
handdatabase SomeDatabase
{
  types 
    // logical name 'int', database name 'int', integer client type
    int as integer,
    // logical name 'number', database name 'numeric', real number client type
    number ("numeric") as real,
    // logical name 'nstring', database type 'nvarchar', string client type
    nstring ("nvarchar") as string;
    
  version 1.0 : initialized
  {
    design
    {
      public table T
      {
        public column C1 with DataType = type(int);
        public column C2 with DataType = type(int null);
        public column C3 with DataType = type(nstring(20));
        public column C4 with DataType = type(nstring(100) null);
        public column C5 with DataType = type(number(10, 3));
        public column C6 with DataType = type(number(12, 4) null);
      }
    }
  }
}

In documentation for syntax element type

You can click on keywords and concepts in blue.
handdatabase SomeDatabase
{
  types 
    int as integer,
    number ("numeric") as real,
    nstring ("nvarchar") as string;
    
  version 1.0 : initialized
  {
    design
    {
      public table T
      {
        // integer not null
        public column C1 with DataType = type(int);
        
        // integer null
        public column C2 with DataType = type(int null);
        
        // nvarchar(20) not null
        public column C3 with DataType = type(nstring(20));
        
        //nvarchar(100) null
        public column C4 with DataType = type(nstring(100) null);
        
        // numeric(10, 3) not null
        public column C5 with DataType = type(number(10, 3));
        
        // numeric(12, 4)
        public column C6 with DataType = type(number(12, 4) null);
      }
    }
  }
}

In documentation for syntax element database

You can click on keywords and concepts in blue.
// declares a database class
handdatabase MyDatabase
{
  // database versions
}
/*
Database declarations are inherently partial
that is, you can have more than one declaration
for the same database class and they are
merged together.
This declaration defines version 1.0 as
the first version fully controlled with
DataClass.
*/
database DatabaseSplitAcrossMultipleFiles
{
  version 1.0 : initialized // ...
}
/*
This declaration defines another version (1.1)
version 1.1 succeeds version 1.0.
*/
database DatabaseSplitAcrossMultipleFiles
{
  version 1.1 : 1.0 // ...
}

In documentation for syntax element version

You can click on keywords and concepts in blue.
// defining the initialized version
handdatabase MyDatabase
{
  version initialized { }
}
// defining a new version for your database
database MyDatabase
{
  version 1.0 : initialized
  {
  }
}

In documentation for syntax element :

You can click on keywords and concepts in blue.
// causes version 1.1 to inherit from version 1.0
handversion 1.1 : 1.0
// causes Y to inherit from X
public table X ("dat_X");
public table Y : X;

In documentation for syntax element design

You can click on keywords and concepts in blue.
// begins declaring the design for a version
handdatabase YourDatabase
{
  // ...
  
  version initialized
  {
    design
    {
      public table ALegacyTable;
    }
  }
}

In documentation for syntax element open curly

You can click on keywords and concepts in blue.
// beginning a design block
handdesign { // ...
// beginning a construction block
construction { // ...
// beginning a database
database { // ...

In documentation for syntax element close curly

You can click on keywords and concepts in blue.
// beginning a design block
handdesign
{
  // ...
}
// beginning a construction block
construction
{
  // ...
}
// beginning a database
database
{
  // ...
}

In documentation for syntax element construction

You can click on keywords and concepts in blue.
handdatabase IndustrialDB
{
  version 2.1 : 2.0
  {
    construction
    {
      // steps to build a database up to the containing version
    }
  }
}

In documentation for syntax element step sql

You can click on keywords and concepts in blue.
handdatabase Links
{
  version initialized
  {
    construction
    {
      step sql
      {
        -- SQL step to initialize a database
      }
    }
  }
  
  version 1.0 : initialized
  {
    construction
    {
      step sql
      {
        -- a SQL step to advance from initialized to 1.0
      }
      step sql
      {
        -- the second step to get from initialized to 1.0
      }
    }
  }
}

In documentation for syntax element initialized

You can click on keywords and concepts in blue.
handdatabase MyLegacyDatabase
{
  version initialized
  {
    // ... attributes of a pre-DataClass database
  }
}

In documentation for syntax element version number

You can click on keywords and concepts in blue.
handdatabase DatabaseWithSomeHistory
{
  version 1.0 : initialized { }
  version 2.0 : 1.0 { }
  version 2.0.1 : 2.0 { }
  version 2.0.1.4 : 2.0.1 { }
}

In documentation for syntax element stereotypes

You can click on keywords and concepts in blue.
handdatabase
{
  stereotypes table, column;
}

In documentation for syntax element with

You can click on keywords and concepts in blue.
handdatabase DB
{
  version 1.0 : initialized
  {
    types int as integer;
    stereotypes table, column;
    
    design
    {
      public table X ("dat_X")
      {
        public column MyColumn with
          public DataType = type(int),
          public SortOrder = "ASC";
      }
    }
  }
}

In documentation for syntax element with validation

You can click on keywords and concepts in blue.
handdatabase MyDatabase
{
  stereotypes column with validation = minimal, table with validation = none;
}

In documentation for syntax element minimal

You can click on keywords and concepts in blue.
handdatabase MyDatabase
{
  stereotypes column with validation = minimal, table with validation = none;
}

In documentation for syntax element table

You can click on keywords and concepts in blue.
handdatabase HasATable
{
  stereotypes table with validation = minimal;
  
  version 1.0 : initialized
  {
    design
    {
      public table X;
    }
  }
}

In documentation for syntax element column

You can click on keywords and concepts in blue.
handdatabase HasATable
{
  types
    int as integer, 
    varstring ("nvarchar") as string,
    number ("numeric") as real;
  stereotype table with validation = minimal;
  
  version 1.0 : initialized
  {
    design
    {
      protected table X
      {
        public column A with DataType = type(int);
        public column B with DataType = type(varstring(5));
        public column C with DataType = type(number(5,2));
      }
    }
  }
}

In documentation for syntax element procedure

You can click on keywords and concepts in blue.
handdatabase HasAProcedure
{
  stereotype procedure with validation = minimal;
  
  version 1.0 : initialized
  {
    design
    {
      public procedure AddKey ("keys_Add");
      public procedure RemoveKey ("keys_Remove");
    }
  }
}

In documentation for syntax element removed

You can click on keywords and concepts in blue.
handpublic table Foo
{
  public column Bar;
}
public table Foo2 : Foo
{
  // Foo2.Bar should not be a valid target of any coupling
  removed Bar;
}

In documentation for syntax element null

You can click on keywords and concepts in blue.
// this integer should be nullable
handtype(int null);

In documentation for syntax element parameter

You can click on keywords and concepts in blue.
handdatabase HasAProcedure
{
  stereotype
    procedure with validation = minimal,
    parameter with validation = minimal;
  
  version 1.0 : initialized
  {
    design
    {
      public procedure AddKey ("keys_Add")
      {
        public parameter Input ("@V");
      }
    }
  }
}

In documentation for syntax element result

You can click on keywords and concepts in blue.
handdatabase HasAProcedure
{
  stereotype
    procedure with validation = minimal,
    parameter with validation = minimal,
    result with validation = minimal;
  
  version 1.0 : initialized
  {
    design
    {
    
      public procedure AddKey ("keys_Add")
      {
        public parameter Input ("@V");
        
        public result Values
        {
          public column A;
        }
      }
    }
  }
}

In documentation for syntax element none

You can click on keywords and concepts in blue.
handdatabase MyDatabase
{
  stereotypes column with validation = minimal, table with validation = none;
}

In documentation for syntax element public

You can click on keywords and concepts in blue.
handdatabase MyDatabase
{
  stereotypes column, table;
  
  version 1.0 : initialized
  {
    protected table X
    {
      public column A;
      public column B;
      
      protected other TransitionSpecificStuff with
        InterestingFact1 = 5,
        InterestingFact2 = "ten";
    }
  }
}

In documentation for syntax element protected

You can click on keywords and concepts in blue.
handdatabase MyDatabase
{
  stereotypes column, table, other;
  
  version 1.0 : initialized
  {
    protected table X
    {
      public column A;
      public column B;
      
      protected other TransitionSpecificStuff with
        InterestingFact1 = 5,
        InterestingFact2 = "ten";
    }
  }
}

In documentation for syntax element in context

You can click on keywords and concepts in blue.
handdatabase SomeDB
{
  stereotypes X, Y, Z;
  version 1.0 : initialized
  {
    design
    {
      protected X something
      {
        public Y somethingElse;
        public Y somethingDifferent;
      
      protected Z with
        protected a = 1,
        protected b = "two";
      }
    }
  
    construction
    {
      in context X.Z
      {
        step sql
        {
          INSERT INTO $[X]($[X.somethingElse], $[X.somethingDifferent])
            VALUES($[a], $[b]);
        }
      }
    }
  }
}

In documentation for syntax element physical name

You can click on keywords and concepts in blue.
handdatabase HasPhysicalNames
{
  types longString ("text") as string;
  
  stereotypes table;
  
  version initialized
  {
    design
    {
      public table FollowsConvention ("tbl_FollowsAConvention");
    }
  }
}

Other Actions

documentation | all examples | use cases | concepts | keywords