-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
164 lines (164 loc) · 4.6 KB
/
Copy pathinit.sql
File metadata and controls
164 lines (164 loc) · 4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
-- ===========================================================
-- Redfish Database Schema
-- MySQL 8+
-- ===========================================================
DROP DATABASE IF EXISTS redfish;
CREATE DATABASE redfish CHARACTER
SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE redfish;
-- ===========================================================
-- Assets
-- ===========================================================
CREATE TABLE Assets (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
notes TEXT NULL,
uTop INT NOT NULL DEFAULT 0,
uBottom INT NOT NULL DEFAULT 0,
uSize INT NOT NULL DEFAULT 1
);
-- ===========================================================
-- PortTypes
-- ===========================================================
CREATE TABLE PortTypes (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL
);
-- ===========================================================
-- Ports
-- ===========================================================
CREATE TABLE Ports (
id INT AUTO_INCREMENT PRIMARY KEY,
assetId INT NOT NULL,
portIndex INT NOT NULL,
portTypeId INT NOT NULL,
CONSTRAINT uq_assetid_index UNIQUE (assetId, portIndex),
CONSTRAINT fk_ports_porttype FOREIGN KEY (portTypeId) REFERENCES PortTypes (id) ON DELETE CASCADE,
CONSTRAINT fk_ports_assets FOREIGN KEY (assetId) REFERENCES Assets (id) ON DELETE CASCADE
);
-- ===========================================================
-- PortConnections
-- ===========================================================
CREATE TABLE PortConnections (
id INT AUTO_INCREMENT PRIMARY KEY,
PortAId INT NOT NULL,
PortBId INT NOT NULL,
CONSTRAINT chk_connection_port_order CHECK (portAId < portBId),
CONSTRAINT uq_portconnection UNIQUE (PortAId, PortBId),
CONSTRAINT fk_porta_ports FOREIGN KEY (PortAId) REFERENCES Ports (id) ON DELETE CASCADE,
CONSTRAINT fk_portb_ports FOREIGN KEY (PortBId) REFERENCES Ports (id) ON DELETE CASCADE
);
-- ===========================================================
-- Test Data
-- ===========================================================
-- -----------------------------------------------------------
-- Assets
-- -----------------------------------------------------------
INSERT INTO Assets (name, notes, uTop, uBottom, uSize)
VALUES (
'Core Switch 01',
'Main core network switch',
1,
2,
2
),
(
'Access Switch 01',
'Access layer switch',
1,
1,
1
),
('Server 01', 'Application server', 2, 0, 2);
-- -----------------------------------------------------------
-- Port Types
-- -----------------------------------------------------------
INSERT INTO PortTypes (id, name)
VALUES (1, 'Ethernet'),
(2, 'SFP'),
(3, 'Fiber'),
(4, 'SFP+'),
(5, 'SFP28'),
(6, 'SFP56'),
(7, 'QSFP'),
(8, 'QSFP+'),
(9, 'QSFP28'),
(10, 'QSFP56'),
(11, 'QSFP-DD'),
(12, 'OSFP'),
(13, 'InfiniBand'),
(14, 'USB-A'),
(15, 'USB-C'),
(16, 'VGA'),
(17, 'HDMI'),
(18, 'DisplayPort'),
(19, 'DB-9'),
(20, 'Console port'),
(21, 'IEC C13 power'),
(22, 'IEC C14 power'),
(23, 'IEC C19 power'),
(24, 'IEC C20 power'),
(25, 'MPO');
-- -----------------------------------------------------------
-- Ports
--
-- Core Switch 01 (Asset 1)
-- Port 1 -> Ethernet
-- Port 2 -> Ethernet
-- Port 3 -> SFP
-- Port 4 -> SFP
--
-- Access Switch 01 (Asset 2)
-- Port 1 -> Ethernet
-- Port 2 -> Ethernet
-- Port 3 -> SFP
--
-- Server 01 (Asset 3)
-- Port 1 -> Ethernet
-- Port 2 -> Ethernet
-- -----------------------------------------------------------
INSERT INTO Ports (assetId, portIndex, portTypeId)
VALUES -- Core Switch 01
(1, 1, 1),
(1, 2, 1),
(1, 3, 2),
(1, 4, 2),
-- Access Switch 01
(2, 1, 1),
(2, 2, 1),
(2, 3, 2),
-- Server 01
(3, 1, 1),
(3, 2, 1);
-- -----------------------------------------------------------
-- Port Connections
--
-- Core Switch 01 Port 1 -> Access Switch 01 Port 1
-- Core Switch 01 Port 2 -> Access Switch 01 Port 2
-- Core Switch 01 Port 3 -> Access Switch 01 Port 3
-- Core Switch 01 Port 4 -> Server 01 Port 1
-- Access Switch 01 Port 2 -> Server 01 Port 2
--
-- Port IDs are:
--
-- Core Switch 01:
-- 1, 2, 3, 4
--
-- Access Switch 01:
-- 5, 6, 7
--
-- Server 01:
-- 8, 9
--
-- -----------------------------------------------------------
INSERT INTO PortConnections (PortAId, PortBId)
VALUES (1, 5),
-- Core 01 port 1 -> Access 01 port 1
(2, 6),
-- Core 01 port 2 -> Access 01 port 2
(3, 7),
-- Core 01 port 3 -> Access 01 port 3
(4, 8),
-- Core 01 port 4 -> Server 01 port 1
(6, 9);
-- Access 01 port 2 -> Server 01 port 2