-
Notifications
You must be signed in to change notification settings - Fork 1
/
database.sql
598 lines (584 loc) · 5.03 KB
/
database.sql
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
CREATE TABLE ALUNO (
nome
VARCHAR(50)
NOT NULL,
matricula
NUMERIC(11)
NOT NULL,
lsigaa
VARCHAR(20)
not null,
ssigaa
varchar(20)
not null,
PRIMARY KEY (matricula)
)
CREATE TABLE PROFESSOR (
nome
varchar(50)
not null,
code
numeric(11),
lsigaa
VARCHAR(20),
ssigaa
varchar(20),
primary key (code)
)
CREATE TABLE FICHAS (
code
int,
nome
varchar(20),
primary key (code)
)
CREATE TABLE TURMA (
code
char(7),
nome
varchar(30),
prof
numeric(11),
primary key (code),
foreign key (prof) references PROFESSOR (code)
)
CREATE TABLE TURMA_ALUNO (
code
int,
periodo
char(6),
codeT
char(7),
matriculaA
numeric(11),
PRIMARY KEY (code),
foreign key (codeT) references TURMA (code),
foreign key (matriculaA) references ALUNO (matricula)
)
CREATE TABLE PACIENTE (
nome
varchar(50),
cpf
char(11),
genero
varchar(10),
data
date,
telefone
numeric(11),
nasc
date,
profissao
varchar(20),
nomep
varchar(50),
nomem
varchar(50),
estado
varchar(20),
cidade
varchar(30),
bairro
varchar(20),
rua
varchar(30),
numero
int,
PRIMARY KEY (cpf)
)
CREATE TABLE ATENDIMENTO (
code
int,
data
date,
cpfP
char(11),
codeTA
int,
codeF
int,
PRIMARY KEY (code),
foreign key (codeTA) references TURMA_ALUNO (code),
foreign key (codeF) references FICHAS (code),
foreign key (cpfP) references PACIENTE (cpf)
)
CREATE TABLE FICHA_TURMA (
codeF
int,
codeT
char(7),
foreign key (codeF) references FICHAS (code),
foreign key (codeT) references TURMA (code)
)
CREATE TABLE FICHA_PERIO (
codeA
int
NOT NULL,
p1
boolean,
p2
boolean,
p3
boolean,
p4
boolean,
p51
boolean,
p52
boolean,
p53
boolean,
p54
boolean,
p55
varchar(50),
p6
boolean,
p61
varchar(50),
p7
boolean,
p71
varchar(50),
p8
boolean,
p81
varchar(50),
p91
boolean,
p92
boolean,
p93
boolean,
p94
boolean,
p95
boolean,
p96
boolean,
p97
boolean,
p98
boolean,
p99
boolean,
p910
boolean,
p911
boolean,
p10
boolean,
p101
varchar(50),
p11
boolean,
p111
boolean,
p12
boolean,
p121
varchar(50),
p122
varchar(20),
p13
boolean,
p131
boolean,
p14
boolean,
p15
boolean,
p16
boolean,
p161
varchar(10),
p162
varchar(3),
p17
boolean,
p171
varchar(30),
p18
boolean,
p19
int,
#odontograma
p20
boolean,
p21
boolean,
p211
int,
p22
boolean,
p221
int,
foreign key (codeA) references ATENDIMENTO (code)
)
CREATE TABLE FICHA_DIAGNOSTICO (
codeA
int
NOT NULL,
p1
varchar(50),
p2
varchar(100),
p3
varchar(20),
p4
varchar(20),
p5
int,
p6
int,
p7
boolean,
p8
boolean,
p9
boolean,
p10
boolean,
p11
boolean,
p12
boolean,
p13
boolean,
p14
boolean,
p15
boolean,
p16
boolean,
p17
boolean,
p171
varchar(20),
p172
varchar(20),
p173
varchar(20),
p18
boolean,
p19
boolean,
p20
boolean,
p201
varchar(20),
p21
boolean,
p211
varchar(20),
p22
boolean,
p23
boolean,
p231
varchar(20),
p24
boolean,
p25
boolean,
p26
boolean,
p261
varchar(20),
p27
boolean,
p271
varchar(20),
p28
boolean,
p281
boolean,
p29
boolean,
p291
boolean,
p30
boolean,
p301
int,
p31
boolean,
p32
boolean,
p33
boolean,
p34
boolean,
p35
boolean,
p36
boolean,
p37
boolean,
p371
varchar(20),
p38
boolean,
p381
varchar(20),
p39
boolean,
p391
varchar(20),
p40
boolean,
p41
boolean,
p42
boolean,
p43
boolean,
p44
boolean,
p45
boolean,
p46
boolean,
p47
boolean,
p471
varchar(20),
p48
boolean,
p481
varchar(20),
pe1
varchar(50),
pe2
varchar(50),
pe3
varchar(50),
pe4
varchar(50),
pe5
varchar(50),
pi1
varchar(50),
pi2
varchar(50),
pi3
varchar(50),
pi4
varchar(50),
pi5
varchar(50),
pi6
varchar(50),
pi7
varchar(50),
pper
varchar(50),
pexam
varchar(100),
#ODONTOGRAMA
pn1
varchar(50),
pn2
varchar(50),
pn3
varchar(50),
pn4
varchar(50),
pn5
varchar(50),
pf
varchar(20),
foreign key (codeA) references ATENDIMENTO (code)
)
CREATE TABLE FICHA_PPR (
codeA
int
NOT NULL,
p1
varchar(20),
p2
varchar(100),
p3
varchar(100),
p4
varchar(20),
p5
varchar(20),
p6
varchar(100),
p7
varchar(100),
p8
varchar(20),
foreign key (codeA) references ATENDIMENTO (code)
)
CREATE TABLE FICHA_ORTODONTIA (
codeA
int
NOT NULL,
pana1
varchar(20),
pana2
int,
pana3
int,
pana4
int,
pana41
varchar(20),
pana5
boolean,
pana6
int,
pana7
int,
pana71
varchar(20),
pana8
int,
pana9
int,
pana91
varchar(20),
pana10
varchar(50),
ppsi
int,
pfront1
boolean,
pfront2
int,
pfront3
boolean,
pfront4
int,
pfront5
int,
pfront6
int,
pfront7
int,
pfront8
int,
pfront9
varchar(50),
pfs1
boolean,
pfs2
int,
pfs3
int,
pfs4
varchar(50),
pper1
int,
pper2
int,
pper3
int,
pper4
boolean,
pper5
int,
pper6
varchar(20),
pper7
int,
pper8
varchar(20),
pper9
int,
pper10
int,
pper11
varchar(20),
pper12
int,
pper13
varchar(50),
pfun1
int,
pfun2
boolean,
pfun3
boolean,
pfun4
int,
pfun5
varchar(20),
pfun6
varchar(20),
poc1
int,
poc2
int,
poc3
int,
poc4
int,
poc5
int,
poc6
int,
poc7
int,
poc8
int,
poc9
int,
poc10
boolean,
poc11
boolean,
poc12
int,
poc13
int,
poc14
int,
poc15
int,
poc16
int,
poc17
int,
poc18
boolean,
poc19
varchar(50),
obs
varchar(50),
penc
int,
foreign key (codeA) references ATENDIMENTO (code)
)
CREATE TABLE FICHA_URGENCIA (
codeA
int
NOT NULL,
p1
varchar(50),
p2
varchar(50),
p3
varchar(50),
p4
varchar(50),
p5
varchar(20),
p6
varchar(50),
p7
varchar(50),
p8
varchar(50),
p9
varchar(20),
foreign key (codeA) references ATENDIMENTO (code)
)
CREATE TABLE FICHA_EXEMPLO (
codeA
int
NOT NULL,
foreign key (codeA) references ATENDIMENTO (code)
)