Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
Added Foreign Keys linking organizations to HIBP
Browse files Browse the repository at this point in the history
Added Foreign keys and relationships to HIBP linking it to Organizations
  • Loading branch information
DJensen94 committed Sep 23, 2021
1 parent 08a378b commit d7aec77
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pe_reports/data/data_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ CREATE TABLE IF NOT EXISTS public.hibp_exposed_credentials
(
hibp_exposed_credentials_uid uuid default uuid_generate_v1() NOT NULL,
email text NOT NULL,
organization text,
organizations_uid uuid NOT NULL,
root_domain text,
sub_domain text,
breach_name text,
Expand All @@ -147,6 +147,7 @@ CREATE TABLE IF NOT EXISTS public.hibp_exposed_credentials
CREATE TABLE IF NOT EXISTS public.cybersix_exposed_credentials
(
csg_exposed_credentials_uid uuid default uuid_generate_v1() NOT NULL,
organizations_uid uuid NOT NULL,
breach_date date,
breach_id integer,
breach_name text NOT NULL,
Expand Down Expand Up @@ -191,12 +192,18 @@ ALTER TABLE public."DNSTwist"
REFERENCES public.domains ("domain_uid")
NOT VALID;

-- One to many relation between Organization and Domains
-- One to many relation between Breaches and HIBP Exposed Credentials
ALTER TABLE public.hibp_exposed_credentials
ADD FOREIGN KEY (breach_id)
REFERENCES public.hibp_breaches (hibp_breaches_uid)
NOT VALID;

-- One to many relation between Organization and HIBP Exposed Credentials
ALTER TABLE public.hibp_exposed_credentials
ADD FOREIGN KEY (organizations_uid)
REFERENCES public.organizations (organizations_uid)
NOT VALID;

-- One to many relation between Organization and Aliases
ALTER TABLE public.alias
ADD FOREIGN KEY (organizations_uid)
Expand Down

0 comments on commit d7aec77

Please sign in to comment.