forked from Francis1408/Web_Car_Shop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-database.ddl
144 lines (121 loc) · 4.42 KB
/
create-database.ddl
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
-- Gerado por Oracle SQL Developer Data Modeler 22.2.0.165.1149
-- em: 2022-11-23 21:38:37 BRT
-- site: Oracle Database 11g
-- tipo: Oracle Database 11g
-- predefined type, no DDL - MDSYS.SDO_GEOMETRY
-- predefined type, no DDL - XMLTYPE
CREATE TABLE anuncio (
descricao VARCHAR2(100),
numero NUMBER(3) NOT NULL,
data DATE NOT NULL,
valor NUMBER NOT NULL,
carro VARCHAR2(7) NOT NULL,
vendedor NUMBER NOT NULL
)
LOGGING;
ALTER TABLE anuncio ADD CONSTRAINT anuncio_pk PRIMARY KEY ( numero );
CREATE TABLE carro (
placa VARCHAR2(7) NOT NULL,
modelo VARCHAR2(20) NOT NULL,
ano NUMBER(4) NOT NULL,
cor VARCHAR2(20) NOT NULL,
marca VARCHAR2(20) NOT NULL
)
LOGGING;
ALTER TABLE carro ADD CONSTRAINT carro_pk PRIMARY KEY ( placa );
CREATE TABLE feedback (
comentario VARCHAR2(200),
avaliacao CHAR(1) NOT NULL,
id NUMBER NOT NULL
)
LOGGING;
ALTER TABLE feedback ADD CONSTRAINT feedback_pk PRIMARY KEY ( id );
CREATE TABLE transacao (
valor NUMBER NOT NULL,
data DATE NOT NULL,
comprador NUMBER NOT NULL,
vendedor NUMBER NOT NULL,
anuncio NUMBER NOT NULL,
feedback_id NUMBER NOT NULL
)
LOGGING;
ALTER TABLE transacao
ADD CONSTRAINT transacao_pk PRIMARY KEY ( comprador,
vendedor,
data,
anuncio );
CREATE TABLE usuario (
email VARCHAR2(30) NOT NULL,
telefone NUMBER NOT NULL,
userid NUMBER NOT NULL,
endereco VARCHAR2(100) NOT NULL,
nome VARCHAR2(50) NOT NULL
)
LOGGING;
ALTER TABLE usuario ADD CONSTRAINT usuario_pk PRIMARY KEY ( userid );
ALTER TABLE anuncio
ADD CONSTRAINT anuncio_carro_fk FOREIGN KEY ( carro )
REFERENCES carro ( placa )
NOT DEFERRABLE;
ALTER TABLE anuncio
ADD CONSTRAINT anuncio_usuario_fk FOREIGN KEY ( vendedor )
REFERENCES usuario ( userid )
NOT DEFERRABLE;
ALTER TABLE transacao
ADD CONSTRAINT transacao_anuncio_fk FOREIGN KEY ( anuncio )
REFERENCES anuncio ( numero )
NOT DEFERRABLE;
ALTER TABLE transacao
ADD CONSTRAINT transacao_feedback_fk FOREIGN KEY ( feedback_id )
REFERENCES feedback ( id )
NOT DEFERRABLE;
ALTER TABLE transacao
ADD CONSTRAINT transacao_usuario_fk FOREIGN KEY ( comprador )
REFERENCES usuario ( userid )
NOT DEFERRABLE;
ALTER TABLE transacao
ADD CONSTRAINT transacao_usuario_fkv2 FOREIGN KEY ( vendedor )
REFERENCES usuario ( userid )
NOT DEFERRABLE;
-- Relatório do Resumo do Oracle SQL Developer Data Modeler:
--
-- CREATE TABLE 5
-- CREATE INDEX 0
-- ALTER TABLE 11
-- CREATE VIEW 0
-- ALTER VIEW 0
-- CREATE PACKAGE 0
-- CREATE PACKAGE BODY 0
-- CREATE PROCEDURE 0
-- CREATE FUNCTION 0
-- CREATE TRIGGER 0
-- ALTER TRIGGER 0
-- CREATE COLLECTION TYPE 0
-- CREATE STRUCTURED TYPE 0
-- CREATE STRUCTURED TYPE BODY 0
-- CREATE CLUSTER 0
-- CREATE CONTEXT 0
-- CREATE DATABASE 0
-- CREATE DIMENSION 0
-- CREATE DIRECTORY 0
-- CREATE DISK GROUP 0
-- CREATE ROLE 0
-- CREATE ROLLBACK SEGMENT 0
-- CREATE SEQUENCE 0
-- CREATE MATERIALIZED VIEW 0
-- CREATE MATERIALIZED VIEW LOG 0
-- CREATE SYNONYM 0
-- CREATE TABLESPACE 0
-- CREATE USER 0
--
-- DROP TABLESPACE 0
-- DROP DATABASE 0
--
-- REDACTION POLICY 0
--
-- ORDS DROP SCHEMA 0
-- ORDS ENABLE SCHEMA 0
-- ORDS ENABLE OBJECT 0
--
-- ERRORS 0
-- WARNINGS 0