I am creating a database using SQL Server 2008 to store prices for securities that are traded in several markets.
For this market, all securities have the same holiday calendar. However, holiday calendars differ from market to market.
I want the following four tables: Market, GoodBusinessDay, Security and SecurityPriceHistory, and I want to ensure that SecurityPriceHistory does not have rows for business days when the market in which the security was sold was closed.
The fields in the tables are as follows:
Market: MarketID (PK), MarketName
GoodBusinessDay: MarketID (FK), SettlementDate (pair - PK)
Security: SecurityID (PK), MarketID (FK), SecurityName
SecurityPriceHistory: this is a question - my preference is SecurityID, SettlementDate, SecurityPrice
How can I define tables this way and ensure that for each row in SecurityPriceHistory there is a corresponding row in GoodBusinessDay?
If I added a column for MarketID in SecurityPriceHistory. I could see how I can do this with two foreign keys (one indicates "Security" and one indicates "GoodBusinessDay"), but this does not seem to be the correct way to do this.
source
share