Tutorial Webpage for

Lecture Cloud- and Web-Technologies

Loading...

Login

Please use user and password as given in the lecture! Please copy the editor's content, as it will be lost due to reloading of the page for the purpose of login.

Username:

Password:

Kotlin - DSL

Write a Domain Specific Language (DSL) for relational algebra expressions. An example of its usage is

val q4 = query {
    projection("A.a", "D.d") {
        union {
            table("A")
            table("B")
            join {
                table("C")
                table("D")
            }
        }
    }
}
println(q4)
table("A") represents a relational table with name "A". union and join can have two or more operands. projection and query can have exactly one operand. If the number of operands is different, then an exception should be thrown (via: throw Exception("message")). Furthermore, you can specify an arbitrary number of attributes with projection. For an arbitrary number of parameters of a function, please consider this link.In this exercise your task is to develop Kotlin code with which one can specify such relational expressions (without providing code to execute the specified relational expression).

Editor

Please use the following editor for your exercise. You can run the content of the editor by clicking on the tab 'Run'...

Output of Editor Content

The result of running the editor content is as follows:

Output of the Solution

The output of the solution is as follows:

Solution

Please have a look at the solution only after you have finished working on your own solution. Otherwise the learn effect is much less.