File: bones2sql

package info (click to toggle)
scotty 2.1.9-1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 9,984 kB
  • ctags: 4,313
  • sloc: ansic: 35,946; sh: 12,591; tcl: 8,122; yacc: 2,442; makefile: 898; lex: 370
file content (266 lines) | stat: -rwxr-xr-x 5,183 bytes parent folder | download
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#! /usr/local/bin/scotty -nf
## -*- tcl -*-
##
## Create a relational model for the bones database. We simply write
## the SQL create table statements to stdout, each statement seperated
## by an empty line. This makes things quite portable.
##
## Copyright (c) 1995
##
## J. Schoenwaelder
## TU Braunschweig, Germany
## Institute for Operating Systems and Computer Networks
##
## Permission to use, copy, modify, and distribute this
## software and its documentation for any purpose and without
## fee is hereby granted, provided that this copyright
## notice appears in all copies.  The University of Braunschweig
## makes no representations about the suitability of this
## software for any purpose.  It is provided "as is" without
## express or implied warranty.
##

proc bones { query } { puts "$query \\g" }

##
## Below are all the table creation statements.
##

bones {
    create table Person (
			 id		int primary key,
			 name		char(80) not null, 
			 address	int,
			 privphone	char(40),
			 email		char(40),
			 phone		char(40),
			 position	char(20),
			 department	int
			 )
}

bones {
    create table Department (
			     id	 	int primary key,
			     name	char(80) not null,
			     address	int not null,
			     head	int
			     )
}

bones {
    create table Project (
			  id	int primary key,
			  name	char(80) not null,
			  descr	char(255),
			  start	int,
			  end	int
			  )
}

bones {
    create table ProjectMember (
				id	int,
				project	int,
				type	char(20),
				start	int,
				end	int
				)
}

bones {
    create table Location (
			   city		char(80) not null,
			   street	char(80) not null,
			   house	char(80) not null,
			   room		char(80)
			   )
}

##
## Here starts the account section. This is modeled very closely
## like the UNIX way of doing things. Perhaps we need future add ons
## to model other operating systems.
##

bones {
    create table Login (
			id	int not null primary key,
			name	char(16) not null,
			passwd	char(16) not null,
			home	char(255) not null,
			shell	char(80) not null,
			group	int not null,
			owner	int
			)
}

bones {
    create table Group (
			id	int not null primary key,
			name	char(16) not null
			)
}
    
bones {
    create table GroupMember (
			      uid	int not null,
			      gid	int not null
			      )
}

##
## The hardware and software section contains tables to model 
## hardware and software information plus the software installation
## and their maintainers.
##

bones {
    create table Hardware (
			   id		int not null primary key,
			   inventNo	int not null,
			   serialNo	int not null,
			   description	char(255) not null,
			   price	int,
			   date		int,
			   type		char(20)
			  )
}

bones {
    create table Software (
			   id		int not null primary key,
			   name		char(40) not null,
			   version	char(40),
			   description	char(255),
			   license	char(80),
			   type		char(20)
			  )
}

bones {
    create table SoftwareInstalled (
				    id		int not null primary key,
				    software	int not null,
				    machines	int,
				    contact	int not null,
				    owner	int
				   )
}

##
## The device section contains definitions for devices like hosts,
## printer disks etc. 
##

bones {
    create table Device (
			 id		int not null primary key,
			 name		char(40) not null,
			 type		char(20),
			 hardware	int,
			 os		char(40),
			 location	int
			)
}

##
## Filesystems, Partitions etc. are of special interest. So we model
## them using the following classes.
##

bones {
    create table Partition (
			    id		int not null primary key,
			    name	char(40),
			    device	int,
			    cylinder	int,
			    sector	int,
			    sectorSize	int,
			    filesystem	int
			   )
}

bones {
    create table Filesystem (
			     id		int not null primary key,
			     name	char(40),
			     type	char(20),
			     readOnly   int,
			     access	char(256),
			     rootAccess	char(256),
			     anonymous	char(20)
			    )
}

##
## Tables used to store network information.
##


bones {
    create table Network (
			  id		int not null primary key,
			  layer		int,
			  name		char(40),
			  type		char(20),
			  speed		int,
			  address	char(40),
			  mask		char(40)
			 )
}

bones {
    create table Interface (
			    id		int not null primary key,
			    name	char(40),
			    address	char(40),
			    device	int,
			    network	int
			   )
}

bones {
    create table Service (
			  id		int not null primary key,
			  name		char(40),
			  protocol	char(20),
			  port		int
			 )
}

exit 0

##
## Some stuff that is currently not part of the model.
##

IPDomain OBJECT CLASS
    SUBCLASS of Audit
    KEY { name }
    MUST CONTAIN {
	name		:: string,
	master		:: device,
	servers		:: device,
	xchangers	:: device,
	devices		:: device[]
    }

-- Netgroups (not to confuse with YP netgroups) are used to define
-- sets of objects to allow very flexible and short configuration
-- descriptions.

Netgroup OBJECT CLASS
    SUBCLASS of Audit
    KEY { name }
    MUST CONTAIN {
	name	:: string,
	devices	:: device[],
	hosts	:: iPInterface[],
	ethers	:: ethernetInterface[],
	groups	:: group[],
	logins	:: login[]
    }
    MAY CONTAIN {
	services	:: iPService[]
    }