Relation:Tutorial 3

Tables

In Belle Nuit Relation, relations are tables, tuples rows and columns properties.
Row and column are not significant and each row is unique.
Tables always have a column header
You can create a table right in Relation. The table below was written with the code you can see on the right of this page.

id title country
1001 Ma vie de Courgette CH
1002 Elle FR
1003 Toni Erdmann DE
1004 Above and Below CH

In the first line relation you create a new relation and define the columns. The columns must be Valid names, eg alphanumeric.
The following insert lines add the rows. In Relation, you write numbers directly and text should be in quotes. However, the columns are not typed. If id in this example is number or text depends on how you use it in expressions.
Finally, print writes the current relation to the note book.
Normally, you will not write data directly into Relation, but from files. For the rest of the tutorial we will use a comma-separated-values file (CSV) films.csv. You can export CSV from Excel, Numbers and many other application, even write manually.

film director year
A bout de souffle Godard 1960
Tirez sur le pianiste Truffaut 1960
Cléo de 5 à 7 Varda 1962
Jules et Jim Truffaut 1962
Pierrot le fou Godard 1965
Week-End Godard 1967
Die verlorene Ehre der Katharina Blum von Trotta 1975
Der starke Ferdinand Kluge 1976
Sans toi ni loi Varda 1985

Every line in the Relation program begins with an instruction. We now have used relation, insert, print and read.
The instructions are executed line by line and may create relations and put it on the stack, manipulate the current relation on top of the stack or combine multiple relations on the stack.
For each instruction, there might options. The relation instruction needs a list of columns, the insert instruction data and the read instruction a filnename.
You may note that there is only a filename and no path. How does Relation know where to look for the file? The file must be in the same folder as the program you write. Relation works in a Sandbox.
Go to Tutorial 4

' ===Tables===

' In Belle Nuit Relation, relations are tables, tuples rows and columns properties.

' Row and column are not significant and each row is unique.

' Tables always have a column header

' You can create a table right in Relation. The table below was written with the code you can see on the right of this page.

relation id, title, country

insert 1001 , "Ma vie de Courgette" , "CH"

insert 1002 , "Elle" , "FR"

insert 1003 , "Toni Erdmann" , "DE"

insert 1004 , "Above and Below" , "CH"

print

' In the first line '''relation''' you create a new relation and define the columns. The columns must be [[valid names]], eg alphanumeric.

' The following '''insert''' lines add the rows. In Relation, you write '''numbers''' directly and '''text''' should be in quotes. However, the columns are not typed. If ''id'' in this example is number or text depends on how you use it in expressions.

' Finally, '''print''' writes the current relation to the note book.

' Normally, you will not write data directly into Relation, but from files. For the rest of the tutorial we will use a comma-separated-values file (CSV) [[Media:films.csv]]. You can export CSV from Excel, Numbers and many other application, even write manually.

read "films.csv"

print

' Every line in the Relation program begins with an instruction. We now have used '''[[relation]]''', '''[[insert]]''', '''[[print]]''' and '''[[read]]'''.

' The instructions are executed line by line and may create relations and put it on the stack, manipulate the current relation on top of the stack or combine multiple relations on the stack.

' For each instruction, there might options. The '''relation''' instruction needs a list of columns, the '''insert''' instruction data and the read instruction a filnename.

' You may note that there is only a filename and no path. How does Relation know where to look for the file? The file must be in the same folder as the program you write. Relation works in a [[sandbox]].

' Go to [[Tutorial 4]]