differential-datalog icon indicating copy to clipboard operation
differential-datalog copied to clipboard

Syntactic separator/terminator for relations

Open blp opened this issue 5 years ago • 2 comments

I initially found it surprising that there's nothing that goes after a relation declaration to terminate it or to separate it from the next declaration. Even now, I occasionally find it confusing since it isn't obvious if the definition of a primary key corresponds to the relation before or after. For example, here's an excerpt from the generated OVN_Southbound.dl for OVN:

primary key (x) x._uuid
input relation Encap (
    _uuid: uuid,
    __type: string,
    options: Map<string,string>,
    ip: string,
    chassis_name: string
)
primary key (x) x._uuid

The (optional?) support for separators or terminators would be helpful.

blp avatar Apr 04 '20 18:04 blp

Another option that would work in this particular situation is to move primary key declaration inside the parenthesis (SQL-style):

primary key (x) x._uuid
input relation Encap (
    _uuid: uuid,
    __type: string,
    options: Map<string,string>,
    ip: string,
    chassis_name: string,
    primary key (x) x._uuid
)

In simple cases where the primary key consist of a single field, we could simply annotate this field (also SQL-style)

primary key (x) x._uuid
input relation Encap (
    _uuid: uuid primary key,
    __type: string,
    options: Map<string,string>,
    ip: string,
    chassis_name: string
)

ryzhyk avatar Apr 04 '20 21:04 ryzhyk

Another option that would work in this particular situation is to move primary key declaration inside the parenthesis (SQL-style):

Good idea.

blp avatar Apr 04 '20 22:04 blp