CREATE TABLE data_user (
	id             INT NOT NULL AUTO_INCREMENT,
	username       VARCHAR(50) NOT NULL,
	active         BIT NOT NULL,
	PRIMARY KEY (id),
	INDEX ix_user__user (username, active)
    )
    ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci;

CREATE TABLE ref_snippet (
	id            INT NOT NULL AUTO_INCREMENT,
	snippet       VARCHAR(2000) NOT NULL,
	active        BIT NOT NULL,
	created_by    VARCHAR(50) NOT NULL,
	PRIMARY KEY (id),
	INDEX ix_snippet__owner (created_by, active)
    )
    ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci;

ALTER TABLE
    `ref_snippet` ADD CONSTRAINT fk_snippet__user__username FOREIGN KEY (`created_by`) REFERENCES
    `data_user` (`username`);
