Data

Relations

Here is a relation literal. It has two parts, each between braces. It has a heading and a body.

{     day_id:int, day_name:str}{
tuple{day_id:=1,  day_name:="Monday"},
tuple{day_id:=2,  day_name:="Tuesday"},
tuple{day_id:=3,  day_name:="Wednesday"},
tuple{day_id:=4,  day_name:="Thursday"},
tuple{day_id:=5,  day_name:="Friday"},
tuple{day_id:=6,  day_name:="Saturday"},
tuple{day_id:=7,  day_name:="Sunday"},
}
┌────────┬───────────┐
│ day_id │ day_name  │
├────────┼───────────┤
│      1 │ Monday    │
│      2 │ Tuesday   │
│      3 │ Wednesday │
│      4 │ Thursday  │
│      5 │ Friday    │
│      6 │ Saturday  │
│      7 │ Sunday    │
└────────┴───────────┘

The heading is a set of attributes. Each attribute has a name and a type. Currently available types include:

Other types will be discussed or added later, particularly support for storing dates and times.

The body is a set of tuples.

Here's a relation literal with a shorthand for the body tuples to simplify typing. This relies on the left-to-right ordering of the values in square brackets aligning with the left-to-right ordering of the heading, but only for loading the relation from the script: after that is has no left-right ordering.

{month_id:int, month_name:str}{
[1,       "January"],
[2,       "February"],
[3,       "March"],
[4,       "April"],
[5,       "May"],
[6,       "June"],
[7,       "July"],
[8,       "August"],
[9,       "September"],
[10,      "October"],
[11,      "November"],
[12,      "December"],
}
┌──────────┬────────────┐
│ month_id │ month_name │
├──────────┼────────────┤
│        1 │ January    │
│        2 │ February   │
│        3 │ March      │
│        4 │ April      │
│        5 │ May        │
│        6 │ June       │
│        7 │ July       │
│        8 │ August     │
│        9 │ September  │
│       10 │ October    │
│       11 │ November   │
│       12 │ December   │
└──────────┴────────────┘