Files
stockdb/db_schema.sql
2024-08-29 21:35:30 -04:00

30 lines
967 B
SQL

CREATE TABLE entities (
cik INT PRIMARY KEY, -- CIK is now the primary key, ensuring uniqueness
name VARCHAR(255) NOT NULL -- Name of the company
);
CREATE TABLE facts (
id VARCHAR(255) PRIMARY KEY, -- Unique identifier for the fact
taxonomy VARCHAR(255), -- Taxonomy of the fact
label VARCHAR(255), -- Label of the fact
description TEXT, -- Description of the fact
unit VARCHAR(255), -- Unit of the fact
);
CREATE TABLE data (
cik INT, -- CIK of the company
fact_id VARCHAR(255),
start DATE, -- Start date of the fact
end DATE,
val INT,
accn VARCHAR(255),
fy INT,
fp VARCHAR(255),
form VARCHAR(255),
filed DATE,
frame VARCHAR(255),
PRIMARY KEY (cik, label)
FOREIGN KEY (cik) REFERENCES entities(cik),
FOREIGN KEY (fact_id) REFERENCES facts(id)
);