DROP TABLE account_struct CASCADE; DROP TABLE account CASCADE; CREATE TABLE account ( id_ integer not null, name_ varchar(255) not null, balance_ decimal(10,2) not null default 0.0 check (type_ <> 'M' OR balance_ = 0.0), type_ char(1) not null check (type_ in ('M', 'D')), primary key (id_) ); CREATE TABLE account_struct ( left_ varchar not null, right_ varchar not null check (right_ = left_ || 'Z'), account_id_ integer not null, primary key (left_), foreign key (account_id_) references account (id_), unique (right_), unique (account_id_) );