Created
October 31, 2025 15:05
-
-
Save ahouts/33d06b9677ba9f8562c41f5d2465ca1a to your computer and use it in GitHub Desktop.
Schema of the trades table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE portfolio | |
| ( | |
| id BIGINT AUTO_INCREMENT PRIMARY KEY | |
| ); | |
| CREATE TABLE trades | |
| ( | |
| id BIGINT AUTO_INCREMENT PRIMARY KEY, | |
| portfolio_id BIGINT NOT NULL, | |
| type VARCHAR(255) NOT NULL, | |
| date DATETIME NOT NULL, | |
| quantity DECIMAL(20, 5) NOT NULL, | |
| CONSTRAINT fk_trades_portfolio_id | |
| FOREIGN KEY (portfolio_id) REFERENCES portfolios (id) | |
| ); | |
| CREATE INDEX trades_portfolio_type_date | |
| ON trades (portfolio_id, type, date); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment