forked from zanfranceschi/rinha-de-backend-2024-q1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.sql
29 lines (25 loc) · 908 Bytes
/
script.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
CREATE TABLE public.clients (
id SERIAL PRIMARY KEY,
"limit" INTEGER NOT NULL,
balance INTEGER NOT NULL
);
CREATE TABLE public.transaction (
id SERIAL PRIMARY KEY,
value INTEGER NOT NULL,
type CHAR(1) NOT NULL,
description VARCHAR(10) NOT NULL,
realized TIMESTAMP NOT NULL DEFAULT NOW(),
"ClientId" INTEGER,
CONSTRAINT "FK_transaction_clients_ClientId" FOREIGN KEY ("ClientId") REFERENCES public.clients (id)
);
CREATE INDEX ids_transaction_ids_client_id ON public.transaction ("ClientId");
INSERT INTO public.clients (id, balance, "limit")
VALUES (1, 0, 100000);
INSERT INTO public.clients (id, balance, "limit")
VALUES (2, 0, 80000);
INSERT INTO public.clients (id, balance, "limit")
VALUES (3, 0, 1000000);
INSERT INTO public.clients (id, balance, "limit")
VALUES (4, 0, 10000000);
INSERT INTO public.clients (id, balance, "limit")
VALUES (5, 0, 500000);