Version 0.2 adds the following changes to CAL.

Optionality of members

Optionality can be specified on a field by adding an optionality suffix to it.
  MyTable <- { Required!, Optional? } INT

If an optionality is not specified then by default it is assumed to be required. You can change this with the @default preprocessor directive. Note that if a field is marked as a key then it will be required irrespective of optionality suffix.

Key fields

Before 0.2 all tables were given an identity field by default. This is sometimes not what is required. You can create your own key fields by adding a star (*) prefix to an existing field.
  Book <- { *Barcode } CHAR(32)

This means that you can create tables with composite keys too if that's your thing.
  ArticleRevision <- { *ArticleNo, *RevNo } INT

Identity Fields

But what if you just want to rename the identity field given to you? You can make a key field an IDENTITY filed by prepending an additional star (*) prefix.
  Member <- { **MemberShipNo } INT

Link Tables no longer have artificial key

With verion 0.1 of Crank if you ran this
Books <> {Loans} Members 

You would end up with a Loans table which had an IDENTITY field called LoanID and two foreign keys BookID and MemberID. With version 0.2 you get a Loans table which contains foreign key references to Books and Members and a composite primary key
  (BookID, MemberID) 

If you actually wanted the artificial key you could do the following
  Book <= Loan => Member 

It might be tempting to do this
  Books <> {Loans} Members
  Loans <- { *LoanID } 

But the result is a Loans table with a triple-composite key
  (LoanID, BookID, MemberID) 

Last edited Nov 28, 2007 at 2:05 AM by michaelminutillo, version 1

Comments

No comments yet.