You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
757 B

CREATE TABLE account (
id SERIAL PRIMARY KEY,
name VARCHAR(48) UNIQUE NOT NULL,
created TIMESTAMP NOT NULL
);
CREATE TABLE balance (
id INT NOT NULL PRIMARY KEY,
gold NUMERIC(16,2) NOT NULL,
FOREIGN KEY (id) REFERENCES account (id)
);
CREATE TABLE transaction (
id SERIAL PRIMARY KEY,
account INT NOT NULL,
withdrawal NUMERIC(16,2),
deposit NUMERIC(16,2),
timestamp TIMESTAMP NOT NULL,
FOREIGN KEY (account) REFERENCES account (id)
);
CREATE TABLE transfer (
id SERIAL PRIMARY KEY,
from_id INT NOT NULL,
to_id INT NOT NULL,
gold NUMERIC(16,2) NOT NULL,
timestamp TIMESTAMP NOT NULL,
FOREIGN KEY (from_id) REFERENCES account (id),
FOREIGN KEY (to_id) REFERENCES account (id)
);