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