1
|
/* ---------------------------------------------------- */
|
2
|
/* Generated by Enterprise Architect Version 13.5 */
|
3
|
/* Created On : 01-dub-2021 15:16:53 */
|
4
|
/* DBMS : SQLite */
|
5
|
/* ---------------------------------------------------- */
|
6
|
|
7
|
/* Drop Tables */
|
8
|
|
9
|
DROP TABLE IF EXISTS 'PrivateKeys'
|
10
|
;
|
11
|
|
12
|
DROP TABLE IF EXISTS 'CertificateTypes'
|
13
|
;
|
14
|
|
15
|
DROP TABLE IF EXISTS 'UsageTypes'
|
16
|
;
|
17
|
|
18
|
DROP TABLE IF EXISTS 'Certificates'
|
19
|
;
|
20
|
|
21
|
DROP TABLE IF EXISTS 'CertificateUsages'
|
22
|
;
|
23
|
|
24
|
/* Create Tables with Primary and Foreign Keys, Check and Unique Constraints */
|
25
|
|
26
|
CREATE TABLE 'PrivateKeys'
|
27
|
(
|
28
|
'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
29
|
'private_key' TEXT NOT NULL,
|
30
|
'password' TEXT NULL
|
31
|
)
|
32
|
;
|
33
|
|
34
|
CREATE TABLE 'CertificateTypes'
|
35
|
(
|
36
|
'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
37
|
'certificate_type' TEXT NOT NULL
|
38
|
)
|
39
|
;
|
40
|
|
41
|
CREATE TABLE 'UsageTypes'
|
42
|
(
|
43
|
'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
44
|
'usage_type' TEXT NOT NULL
|
45
|
)
|
46
|
;
|
47
|
|
48
|
CREATE TABLE 'Certificates'
|
49
|
(
|
50
|
'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
51
|
'common_name' TEXT NOT NULL,
|
52
|
'valid_from' TEXT NOT NULL,
|
53
|
'valid_to' TEXT NOT NULL,
|
54
|
'pem_data' TEXT NOT NULL,
|
55
|
'private_key_id' INTEGER NOT NULL,
|
56
|
'certificate_type_id' INTEGER NOT NULL,
|
57
|
'parent_certificate_id' INTEGER NOT NULL,
|
58
|
CONSTRAINT 'FK_Certificates' FOREIGN KEY ('parent_certificate_id') REFERENCES 'Certificates' ('id') ON DELETE No Action ON UPDATE No Action,
|
59
|
CONSTRAINT 'FK_CertificateTypes' FOREIGN KEY ('certificate_type_id') REFERENCES 'CertificateTypes' ('id') ON DELETE No Action ON UPDATE No Action,
|
60
|
CONSTRAINT 'FK_PrivateKeys' FOREIGN KEY ('private_key_id') REFERENCES 'PrivateKeys' ('id') ON DELETE No Action ON UPDATE No Action
|
61
|
)
|
62
|
;
|
63
|
|
64
|
CREATE TABLE 'CertificateUsages'
|
65
|
(
|
66
|
'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
67
|
'certificate_id' INTEGER NOT NULL,
|
68
|
'usage_type_id' INTEGER NOT NULL,
|
69
|
CONSTRAINT 'FK_Certificates' FOREIGN KEY ('certificate_id') REFERENCES 'Certificates' ('id') ON DELETE Cascade ON UPDATE No Action,
|
70
|
CONSTRAINT 'FK_UsageTypes' FOREIGN KEY ('usage_type_id') REFERENCES 'UsageTypes' ('id') ON DELETE No Action ON UPDATE No Action
|
71
|
)
|
72
|
;
|