/* ---------------------------------------------------- */ /* Generated by Enterprise Architect Version 13.5 */ /* Created On : 01-dub-2021 15:16:53 */ /* DBMS : SQLite */ /* ---------------------------------------------------- */ /* Drop Tables */ DROP TABLE IF EXISTS 'PrivateKeys' ; DROP TABLE IF EXISTS 'CertificateTypes' ; DROP TABLE IF EXISTS 'UsageTypes' ; DROP TABLE IF EXISTS 'Certificates' ; DROP TABLE IF EXISTS 'CertificateUsages' ; /* Create Tables with Primary and Foreign Keys, Check and Unique Constraints */ CREATE TABLE 'PrivateKeys' ( 'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 'private_key' TEXT NOT NULL, 'password' TEXT NULL ) ; CREATE TABLE 'CertificateTypes' ( 'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 'certificate_type' TEXT NOT NULL ) ; CREATE TABLE 'UsageTypes' ( 'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 'usage_type' TEXT NOT NULL ) ; CREATE TABLE 'Certificates' ( 'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 'common_name' TEXT NOT NULL, 'valid_from' TEXT NOT NULL, 'valid_to' TEXT NOT NULL, 'pem_data' TEXT NOT NULL, 'private_key_id' INTEGER NOT NULL, 'certificate_type_id' INTEGER NOT NULL, 'parent_certificate_id' INTEGER NOT NULL, CONSTRAINT 'FK_Certificates' FOREIGN KEY ('parent_certificate_id') REFERENCES 'Certificates' ('id') ON DELETE No Action ON UPDATE No Action, CONSTRAINT 'FK_CertificateTypes' FOREIGN KEY ('certificate_type_id') REFERENCES 'CertificateTypes' ('id') ON DELETE No Action ON UPDATE No Action, CONSTRAINT 'FK_PrivateKeys' FOREIGN KEY ('private_key_id') REFERENCES 'PrivateKeys' ('id') ON DELETE No Action ON UPDATE No Action ) ; CREATE TABLE 'CertificateUsages' ( 'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 'certificate_id' INTEGER NOT NULL, 'usage_type_id' INTEGER NOT NULL, CONSTRAINT 'FK_Certificates' FOREIGN KEY ('certificate_id') REFERENCES 'Certificates' ('id') ON DELETE Cascade ON UPDATE No Action, CONSTRAINT 'FK_UsageTypes' FOREIGN KEY ('usage_type_id') REFERENCES 'UsageTypes' ('id') ON DELETE No Action ON UPDATE No Action ) ;