2023-05-23 10:01:41 +00:00
|
|
|
-- 账户表
|
2023-05-21 15:00:12 +00:00
|
|
|
CREATE TABLE account (
|
2023-05-28 04:07:16 +00:00
|
|
|
a_id SERIAL PRIMARY KEY, -- 账户号
|
|
|
|
balance MONEY, -- 余额
|
|
|
|
meta JSONB -- 元数据
|
2023-05-21 15:00:12 +00:00
|
|
|
);
|
2023-05-23 10:01:41 +00:00
|
|
|
-- {"name":"name",
|
2023-05-28 04:07:16 +00:00
|
|
|
-- time:"2022-02-02",
|
2023-05-23 10:01:41 +00:00
|
|
|
-- “budget": [
|
|
|
|
-- {"time":"2022-02","value":20.32},
|
|
|
|
-- {"time":"2022-01","value":30.32}
|
|
|
|
-- ]
|
|
|
|
-- "discription":"something"}
|
2023-05-21 15:00:12 +00:00
|
|
|
|
2023-05-23 10:01:41 +00:00
|
|
|
-- 类别表
|
2023-05-21 15:00:12 +00:00
|
|
|
CREATE TABLE category (
|
2023-05-23 11:30:58 +00:00
|
|
|
c_id SERIAL PRIMARY KEY, -- 类别号
|
|
|
|
meta JSONB -- 元数据
|
2023-05-21 15:00:12 +00:00
|
|
|
);
|
2023-05-23 10:01:41 +00:00
|
|
|
-- {"name":"name",
|
|
|
|
-- "type":"in"/"out",
|
|
|
|
-- “budget": [
|
|
|
|
-- {"time":"2022-02","value":20.32},
|
|
|
|
-- {"time":"2022-01","value":30.32}
|
|
|
|
-- ]
|
|
|
|
-- "discription":"something"}
|
2023-05-21 15:00:12 +00:00
|
|
|
|
2023-05-23 10:01:41 +00:00
|
|
|
-- 流水表
|
2023-05-21 15:00:12 +00:00
|
|
|
CREATE TABLE transaction (
|
2023-05-23 11:30:58 +00:00
|
|
|
t_id SERIAL PRIMARY KEY, -- 流水号
|
2023-06-03 06:09:06 +00:00
|
|
|
a_id INTEGER REFERENCES account(a_id) NOT NULL, -- 关联账户号
|
|
|
|
c_id INTEGER REFERENCES category(c_id), -- 关联类别号
|
|
|
|
s_id INTEGER REFERENCES category(c_id), -- 源账户号
|
|
|
|
time TIMESTAMP,
|
2023-05-28 04:07:16 +00:00
|
|
|
amount MONEY,
|
2023-05-23 11:30:58 +00:00
|
|
|
meta JSONB -- 元数据
|
2023-05-21 15:00:12 +00:00
|
|
|
);
|
2023-05-23 10:01:41 +00:00
|
|
|
-- {"discription":"something",(可选)
|
2023-06-03 06:09:06 +00:00
|
|
|
-- "type":"in"/"out"/"transfer"/"init"/"modify",
|
2023-05-23 11:30:58 +00:00
|
|
|
|
2023-05-23 10:01:41 +00:00
|
|
|
-- "reimburse":{ (报销)
|
|
|
|
-- "finish": true,
|
|
|
|
-- "ref":t_id
|
|
|
|
-- }
|
|
|
|
-- "":"something"}
|
2023-05-21 15:00:12 +00:00
|
|
|
|
2023-05-23 11:30:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2023-05-21 15:00:12 +00:00
|
|
|
|