# Pastebin UGwTrDBo #`{{{ create table person ( id integer serial, key varchar(255) unique not null, last varchar(255) not null, first varchar(255) not null notes varchar(255) ); }}} model Person { has UInt $!id is serial; has Str $.key is column{ :unique }; has Str $.last is column; has Str $.first is column; has Str $.notes is column{ :nullable }; has @.email is relationship{ *.person-key, :model } has @.attends is relationship{ *.person-key, :model } has @.presents is relationship{ *.person-key, :model } } #`{{{ create table attend ( person_key varchar(255) not null, year integer not null, notes varchar(255), UNIQUE (person_key, year) ); }}} model Attend { has UInt $!id is serial; has UInt $!person-key is referencing{ :model, :column }; has UInt $.year is column; has Str $.notes is column; ::?CLASS.^add-unique-counsraint: { .person-key, .year }; has $.owner is relationship{ { .person-key }, :model } } #`{{{ create table present ( person_key varchar(255) not null, year integer not null, notes varchar(255), UNIQUE (person_key, year) ); }}} model Present { has UInt $!id is serial; has UInt $!person-key is referencing{ :model, :column }; has UInt $.year is column; has Str $.notes is column; ::?CLASS.^add-unique-counsraint: { .person-key, .year }; has $.owner is relationship{ { .person-key }, :model } } #`{{{ create table email ( person_key varchar(255) not null, email varchar(255) not null, notes varchar(255), status integer, UNIQUE (person_key, email) ); }}} model Email { has Str $email is id; has UInt $!person-key is referencing{ :model, :column }; has Str $.notes is column; ::?CLASS.^add-unique-counsraint: { .person-key, .year }; has $.owner is relationship{ { .person-key }, :model } }