diff options
Diffstat (limited to 'sql/dawn.sql')
| -rw-r--r-- | sql/dawn.sql | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql index b95026be..e6a5a4fb 100644 --- a/sql/dawn.sql +++ b/sql/dawn.sql @@ -43,52 +43,56 @@ CREATE INDEX ON counterparties(name); CREATE TABLE bonds(id serial primary key, dealid varchar(28), - lastupdate timestamp, + lastupdate timestamp DEFAULT now(), action action, - folder bond_strat, - custodian varchar(12), - cashaccount varchar(10), + folder bond_strat NOT NULL, + custodian varchar(12) NOT NULL, + cashaccount varchar(10) NOT NULL, cp_code varchar(12) REFERENCES counterparties(code), - trade_date date, - settle_date date, + trade_date date NOT NULL, + settle_date date NOT NULL, cusip varchar(9), isin varchar(12), - description varchar(32), - faceamount float, - price float, - accrued float, + identifier varchar(12), + description varchar(32) NOT NULL, + faceamount float NOT NULL, + price float NOT NULL, + accrued float NOT NULL, asset_class asset_class, ticket text, principal_payment float, - accrued_payment float); + accrued_payment float, + CONSTRAINT bonds2_check CHECK (cusip IS NOT NULL OR isin IS NOT NULL)); CREATE TABLE cds(id serial primary key, dealid varchar(28), - lastupdate timestamp, + lastupdate timestamp DEFAULT now(), action action, - folder cds_strat, - custodian varchar(12), - cashaccount varchar(10), - cp_code varchar(12), - trade_date date, - effective_date date, - maturity date, - currency currency, - payment_rolldate bus_day_convention, - notional float, - fixed_rate float, - day_count day_count, - frequency smallint, - protection protection, - security_id varchar(12), - security_desc varchar(32), - upfront float, - upfront_settle_date date, - swap_type swap_type, + folder cds_strat NOT NULL, + custodian varchar(12) NOT NULL, + cashaccount varchar(10) NOT NULL, + cp_code varchar(12) NOT NULL, + trade_date date NOT NULL, + effective_date date NOT NULL, + maturity date NOT NULL, + currency currency NOT NULL, + payment_rolldate bus_day_convention NOT NULL, + notional float NOT NULL, + fixed_rate float NOT NULL, + day_count day_count NOT NULL, + frequency smallint NOT NULL, + protection protection NOT NULL, + security_id varchar(12) NOT NULL, + security_desc varchar(32) NOT NULL, + upfront float NOT NULL, + upfront_settle_date date NOT NULL, + swap_type swap_type NOT NULL, attach smallint, detach smallint, clearing_facility varchar(12), - isda_definition isda); + isda_definition isda, + CONSTRAINT tranche_check CHECK (swap_type != 'CD_INDEX_TRANCHE' OR + (attach IS NOT NULL AND detach IS NOT NULL))); CREATE TABLE securities(identifier varchar(12) PRIMARY KEY, cusip varchar(9), |
