SQL CREATE TABLE
The following command will create a table called rent_payments
with 5 data columns, a primary key constraint on the id
column, and a foreign key to the tenant
table.
-- Works in PostgreSQL, MySQL, SQL Server, and Oracle
CREATE TABLE rent_payments(
id INT PRIMARY KEY,
tenant_id INT,
building_address VARCHAR(100),
dollar_amount decimal(6, 2) NOT NULL,
payment_date DATE,
FOREIGN KEY (tenant_id) REFERENCES tenant(id);