Skip to content

Commit

Permalink
feat: init sql added
Browse files Browse the repository at this point in the history
  • Loading branch information
enaenen committed Nov 30, 2023
1 parent 466952b commit d55523e
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions db/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
CREATE TABLE USER_INFO
(
USER_ID INT NOT NULL PRIMARY KEY,
LOGIN VARCHAR(50) NOT NULL,
IS_ADMIN BOOLEAN NOT NULL DEFAULT FALSE,
CONSTRAINT IDX_UNIQUE UNIQUE (USER_ID)
);

CREATE TABLE CARD_ISSUANCE
(
IDX BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
USER_ID INT NOT NULL,
CARD_ID VARCHAR(20) NOT NULL,
START_USE DATETIME NOT NULL,
END_USE DATETIME NOT NULL DEFAULT '9999-12-31 23:59:59',
CONSTRAINT FK_USER_ID FOREIGN KEY (USER_ID) REFERENCES USER_INFO (USER_ID),
CONSTRAINT IDX_UNIQUE UNIQUE (IDX)
);

CREATE TABLE DEVICE_INFO
(
DEVICE_ID INT NOT NULL PRIMARY KEY,
CAMPUS VARCHAR(15) NOT NULL,
IO_TYPE VARCHAR(3) NOT NULL,
CONSTRAINT DEVICE_ID_UNIQUE UNIQUE (DEVICE_ID)
);

CREATE TABLE TAG_LOG
(
IDX BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
TAG_AT DATETIME NOT NULL,
CARD_ID VARCHAR(15) NOT NULL,
DEVICE_ID INT NOT NULL,
CONSTRAINT IDX_UNIQUE UNIQUE (IDX)
);

CREATE TABLE PAIR_INFO
(
IN_DEVICE INT NOT NULL,
OUT_DEVICE INT NOT NULL,
CONSTRAINT PAIR_INFO_PK PRIMARY KEY (IN_DEVICE, OUT_DEVICE)
);

0 comments on commit d55523e

Please sign in to comment.