A tax identification number identifies a company for tax and related administrative purposes. Store it with a tax identification type rather than assuming every organization uses an SSN or EIN. section 10.2.1
A practical company schema treats the identifier as a validated, typed field:
- Use tax_id_type to distinguish SSN, EIN, ITIN, ATIN, and PTIN. section 10.2.1
- Use tax_id_number as a required VARCHAR(9) value, with EIN as the default because companies commonly use it. section 10.2.1
- Enforce expected type values through a database enum, helping prevent erroneous data entry. section 10.2.1
Listing 10.1 Table to store company details
CREATE TABLE company (
company_id UUID PRIMARY KEY
DEFAULT uuid_generate_v4(),
name VARCHAR(255) NOT NULL,
tax_id_type TIN_TYPE NOT NULL DEFAULT 'EIN', #1
tax_id_number VARCHAR(9) NOT NULL,
ach_company_id NUMERIC(10) NOT NULL, #2
duns NUMERIC(9) DEFAULT NULL, #3
logo BYTEA DEFAULT NULL, #4
website VARCHAR(255) DEFAULT NULL,
industry INDUSTRY_TYPE DEFAULT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
);
The company table shows the identifier alongside its type, company identity, ACH identifier, and other administrative fields. section 10.2.1
