@startuml
!include "../../atom_files/styles/erd.puml"

'diagram title'
title PB-305 ERD 9: Customer offboarding - Terms And Conditions Archive

'a brief description of the diagram'
legend top
-- \t**Abstract:**\t --
This ERD describes the archival requirements for an offboarding customer's terms
and conditions

//Only foreign keys are included on the tables//
end legend

namespace TERMS_AND_CONDITIONS_ARCHIVE {

  table(PRODUCT, "PRODUCT") {
  'table primary key'
  primary_key(PRODUCT_UID)
  'table columns'
  ==
  red(Reference table - ARCHIVE ONLY)
  }

  table(TERMS_AND_COND_ACCEPT, "TERMS_AND_COND_ACCEPT") {
  'table primary key'
  primary_key(TERMS_AND_COND_ACCEPT_UID)
  --
  'table columns'
  foreign_key(CUSTOMER_UID)
  foreign_key(VAQUINHA_INVITATION_UID)
  foreign_key(PROPOSAL_UID)
  not_null(foreign_key(TERMS_AND_CONDITIONS_UID))
  foreign_key(GOAL_UID)
  foreign_key(PORTFOLIO_UID)
  foreign_key(CUSTOMER_PORTFOLIO_FUND_UID)
  foreign_key(PORTFOLIO_ORDER_UID)
  foreign_key(RECURRING_INVESTMENT_UID)
  ==
  red(Archive and delete)
  ==
  red(Delete order: 1)
  All rows belonging to the offboarding customer.
  }

  table(TERMS_AND_CONDITIONS, "TERMS_AND_CONDITIONS") {
  'table primary key'
  primary_key(TERMS_AND_CONDITIONS_UID)
  --
  'table columns'
  foreign_key(DOCUMENT_TYPE_UID)
  foreign_key(PRODUCT_UID)
  ==
  red(Reference table - ARCHIVE ONLY)
  }

  TERMS_AND_COND_ACCEPT->TERMS_AND_CONDITIONS: TERMS_AND_CONDITIONS_UID
  TERMS_AND_CONDITIONS-up->PRODUCT: PRODUCT_UID
}

table(CUSTOMER, "CUSTOMER") {
'table primary key'
primary_key(CUSTOMER_UID)
'table columns'
}

TERMS_AND_CONDITIONS_ARCHIVE.TERMS_AND_COND_ACCEPT-left->CUSTOMER: CUSTOMER_UID

@enduml
