federationlib/database/associations.sql
2023-06-04 14:23:51 -04:00

29 lines
1.5 KiB
SQL

create table associations
(
child_peer varchar(256) not null comment 'The child peer',
parent_peer varchar(256) not null comment 'The parent peer',
type varchar(32) not null comment 'The association type between the parent peer to the child peer',
client_uuid varchar(36) not null comment 'The client UUID that made the association between the two peers',
timestamp bigint default unix_timestamp() not null comment 'The Unix Timestamp for when this assoication was made',
constraint associations_child_peer_parent_peer_uindex
unique (child_peer, parent_peer),
constraint associations_child_peer_type_parent_peer_uindex
unique (child_peer, type, parent_peer),
constraint associations_clients_uuid_fk
foreign key (client_uuid) references clients (uuid),
constraint associations_discovered_peers_federated_address_fk
foreign key (child_peer) references peers (federated_address),
constraint associations_discovered_peers_federated_address_fk2
foreign key (parent_peer) references peers (federated_address)
)
comment 'A table used for housing associations detected between peers';
create index associations_child_peer_index
on associations (child_peer);
create index associations_client_uuid_index
on associations (client_uuid);
create index associations_parent_peer_index
on associations (parent_peer);