LuggageTracker/formatDB.sql
2025-07-14 22:08:10 -04:00

43 lines
1.2 KiB
SQL

CREATE TABLE addresses (
id BIGINT NOT NULL AUTO_INCREMENT,
street1 TEXT NOT NULL ,
street2 TEXT,
city TEXT NOT NULL ,
state TEXT,
postal_code TEXT NOT NULL,
country TEXT NOT NULL,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE users (
id BIGINT NOT NULL AUTO_INCREMENT,
user_name TEXT NOT NULL,
contact_name TEXT NOT NULL,
secret_codes TEXT NOT NULL,
current_token TEXT,
token_creation TIMESTAMP,
contact_number TEXT NOT NULL,
email_address TEXT NOT NULL,
mailing_address BIGINT NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (mailing_address) REFERENCES addresses(id),
UNIQUE (user_name)
);
CREATE TABLE accounts(
id BIGINT NOT NULL AUTO_INCREMENT,
email TEXT NOT NULL,
passwordHash TEXT NOT NULL,
PRIMARY KEY (id),
UNIQUE (email)
);
CREATE TABLE registration_codes(
id BIGINT AUTO_INCREMENT NOT NULL,
registration_code TEXT NOT NULL,
expiration TIMESTAMP NOT NULL,
PRIMARY KEY (id),
UNIQUE (registration_code)
);