/*
 * Project InfoCard, minimal database
*/


--Where we store user (PERMANENT DATA)
CREATE TABLE USERS (
	name VARCHAR(32),
	cleartext_password VARCHAR(32),
	PRIMARY KEY (name)
);


--Users connected to the system (TEMPORAL DATA)
CREATE TABLE CONNECTED_USERS (
	name VARCHAR(32),
	card_id VARCHAR UNIQUE,
	self_card_id VARCHAR UNIQUE NOT NULL,
	login_time TIMESTAMP DEFAULT NOW(),
	auth_method VARCHAR(32),
	PRIMARY KEY (name),
	FOREIGN KEY (name) REFERENCES USERS (name)
);


--
-- CREATE TABLE ISSUED_CARDS (
-- 	name VARCHAR(32),
-- 	credential_card_id VARCHAR,
-- 	issued_time TIMESTAMP,
-- 	issued_card_id VARCHAR,
-- 	PRIMARY KEY (name),
-- 	FOREIGN KEY (name) REFERENCES USERS (name)
-- );