142 lines
5.2 KiB
SQL
142 lines
5.2 KiB
SQL
CREATE TABLE MEDALLA(
|
|
ID_MEDALLA NUMBER GENERATED ALWAYS AS IDENTITY(START WITH 1 INCREMENT BY 1),
|
|
DESCRIPCION VARCHAR2(50),
|
|
CONSTRAINT MEDALLA_PK PRIMARY KEY (ID_MEDALLA)
|
|
);
|
|
|
|
CREATE TABLE CATEGORIA(
|
|
ID_CATEGORIA NUMBER GENERATED ALWAYS AS IDENTITY(START WITH 1 INCREMENT BY 1),
|
|
DESCRIPCION VARCHAR(50),
|
|
CONSTRAINT CATEGORIA_PK PRIMARY KEY (ID_CATEGORIA)
|
|
);
|
|
|
|
CREATE TABLE ATLETA (
|
|
ID_ATLETA NUMBER GENERATED ALWAYS AS IDENTITY(START WITH 1 INCREMENT BY 1),
|
|
NOMBRE VARCHAR2(50),
|
|
APELLIDO VARCHAR2(50),
|
|
FECHA_NACIMIENTO DATE,
|
|
NACIONALIDAD VARCHAR2(50),
|
|
CONSTRAINT ATLETA_PK PRIMARY KEY (ID_ATLETA)
|
|
);
|
|
|
|
CREATE TABLE PAIS(
|
|
ID_PAIS NUMBER GENERATED ALWAYS AS IDENTITY(START WITH 1 INCREMENT BY 1),
|
|
NOMBRE VARCHAR(50),
|
|
CONSTRAINT PAIS_PK PRIMARY KEY (ID_PAIS)
|
|
);
|
|
|
|
CREATE TABLE TIPOS_DEPORTES(
|
|
ID_TIPO NUMBER GENERATED ALWAYS AS IDENTITY(START WITH 1 INCREMENT BY 1),
|
|
DESCRIPCION VARCHAR(50),
|
|
CONSTRAINT TIPO_PK PRIMARY KEY (ID_TIPO)
|
|
);
|
|
|
|
CREATE TABLE CIUDAD (
|
|
ID_CIUDAD NUMBER,
|
|
NOMBRE VARCHAR(50),
|
|
PAIS NUMBER,
|
|
CONSTRAINT CIUDAD_PK PRIMARY KEY (ID_CIUDAD),
|
|
CONSTRAINT CIUDAD_PAIS_FK FOREIGN KEY (PAIS) REFERENCES PAIS(ID_PAIS)
|
|
);
|
|
|
|
CREATE TABLE LUGAR (
|
|
ID_LUGAR NUMBER GENERATED ALWAYS AS IDENTITY(START WITH 1 INCREMENT BY 1),
|
|
NOMBRE VARCHAR2(50),
|
|
CAPACIDAD NUMBER,
|
|
CIUDAD NUMBER,
|
|
CONSTRAINT LUGAR_PK PRIMARY KEY (ID_LUGAR),
|
|
CONSTRAINT LUGAR_CIUDAD_FK FOREIGN KEY (CIUDAD) REFERENCES CIUDAD(ID_CIUDAD)
|
|
);
|
|
|
|
CREATE TABLE HOTEL(
|
|
ID_HOTEL NUMBER GENERATED ALWAYS AS IDENTITY(START WITH 1 INCREMENT BY 1),
|
|
NOMBRE VARCHAR2(50),
|
|
CIUDAD NUMBER,
|
|
CONSTRAINT HOTEL_PK PRIMARY KEY (ID_HOTEL),
|
|
CONSTRAINT HOTEL_CIUDAD_FK FOREIGN KEY (CIUDAD) REFERENCES CIUDAD(ID_CIUDAD)
|
|
);
|
|
|
|
CREATE TABLE CAPITAL(
|
|
ID_PAIS NUMBER,
|
|
ID_CIUDAD NUMBER,
|
|
CONSTRAINT CAPITAL_PK PRIMARY KEY (ID_PAIS, ID_CIUDAD),
|
|
CONSTRAINT CAPITAL_PAIS_FK FOREIGN KEY (ID_PAIS) REFERENCES PAIS(ID_PAIS),
|
|
CONSTRAINT CAPITAL_CIUDAD_FK FOREIGN KEY (ID_CIUDAD) REFERENCES CIUDAD(ID_CIUDAD)
|
|
);
|
|
|
|
CREATE TABLE DELEGACION(
|
|
ID_DELEGACION NUMBER GENERATED ALWAYS AS IDENTITY(START WITH 1 INCREMENT BY 1),
|
|
NOMBRE VARCHAR2(50),
|
|
CANTIDAD_ATLETAS NUMBER,
|
|
PAIS NUMBER,
|
|
ATLETA NUMBER,
|
|
CONSTRAINT DELEGACION_PK PRIMARY KEY (ID_DELEGACION),
|
|
CONSTRAINT DELEGACION_PAIS_FK FOREIGN KEY (PAIS) REFERENCES PAIS(ID_PAIS),
|
|
CONSTRAINT DELEGACION_ATLETA_FK FOREIGN KEY (ATLETA) REFERENCES ATLETA(ID_ATLETA)
|
|
);
|
|
|
|
CREATE TABLE COMPETENCIA(
|
|
ID_COMPETENCIA NUMBER GENERATED ALWAYS AS IDENTITY(START WITH 1 INCREMENT BY 1),
|
|
NOMBRE VARCHAR2(50),
|
|
CATEGORIA NUMBER,
|
|
TIPO NUMBER,
|
|
LUGAR NUMBER,
|
|
CONSTRAINT COMPETENCIA_PK PRIMARY KEY (ID_COMPETENCIA),
|
|
CONSTRAINT COMPETENCIA_CATEGORIA_FK FOREIGN KEY (CATEGORIA) REFERENCES CATEGORIA(ID_CATEGORIA),
|
|
CONSTRAINT COMPETENCIA_TIPO_FK FOREIGN KEY (TIPO) REFERENCES TIPOS_DEPORTES(ID_TIPO),
|
|
CONSTRAINT COMPETENCIA_LUGAR_FK FOREIGN KEY (LUGAR) REFERENCES LUGAR(ID_LUGAR)
|
|
);
|
|
|
|
CREATE TABLE PRECOMPETENCIA(
|
|
ID_PRECOMPETENCIA NUMBER GENERATED ALWAYS AS IDENTITY(START WITH 1 INCREMENT BY 1),
|
|
FECHA DATE,
|
|
COMPETENCIA NUMBER,
|
|
LUGAR NUMBER,
|
|
CONSTRAINT PRECOMPETENCIA_PK PRIMARY KEY (ID_PRECOMPETENCIA),
|
|
CONSTRAINT PRECOMPETENCIA_COMPETENCIA_FK FOREIGN KEY (COMPETENCIA) REFERENCES COMPETENCIA(ID_COMPETENCIA),
|
|
CONSTRAINT PRECOMPETENCIA_LUGAR_FK FOREIGN KEY (LUGAR) REFERENCES LUGAR(ID_LUGAR)
|
|
);
|
|
|
|
CREATE TABLE HOSPEDAR(
|
|
ID_HOTEL NUMBER,
|
|
ID_DELEGACION NUMBER,
|
|
FECHA_INICIO DATE,
|
|
FECHA_FIN DATE,
|
|
PRECIO_DELEGACION NUMBER,
|
|
PRECIO_ATLETA NUMBER,
|
|
CONSTRAINT HOSPEDAR_PK PRIMARY KEY (ID_HOTEL, ID_DELEGACION, FECHA_INICIO),
|
|
CONSTRAINT HOSPEDAR_HOTEL_FK FOREIGN KEY (ID_HOTEL) REFERENCES HOTEL(ID_HOTEL),
|
|
CONSTRAINT HOSPEDAR_DELEGACION_FK FOREIGN KEY (ID_DELEGACION) REFERENCES DELEGACION(ID_DELEGACION)
|
|
);
|
|
|
|
CREATE TABLE GANAR(
|
|
ID_ATLETA NUMBER,
|
|
ID_COMPETENCIA NUMBER,
|
|
ID_MEDALLA NUMBER,
|
|
FECHA DATE,
|
|
PUNTAJE NUMBER,
|
|
CONSTRAINT GANAR_PK PRIMARY KEY (ID_ATLETA, ID_COMPETENCIA, FECHA),
|
|
CONSTRAINT GANAR_ATLETA_FK FOREIGN KEY (ID_ATLETA) REFERENCES ATLETA(ID_ATLETA),
|
|
CONSTRAINT GANAR_COMPETENCIA_FK FOREIGN KEY (ID_COMPETENCIA) REFERENCES COMPETENCIA(ID_COMPETENCIA),
|
|
CONSTRAINT GANAR_MEDALLA_FK FOREIGN KEY (ID_MEDALLA) REFERENCES MEDALLA(ID_MEDALLA)
|
|
);
|
|
|
|
CREATE TABLE PARTICIPAR_COMPETENCIA(
|
|
ID_COMPETENCIA NUMBER,
|
|
ID_ATLETA NUMBER,
|
|
FECHA DATE,
|
|
CONSTRAINT PARTICIPAR_COMPETENCIA_PK PRIMARY KEY (ID_COMPETENCIA, ID_ATLETA, FECHA),
|
|
CONSTRAINT PARTICIPAR_COMPETENCIA_COMPETENCIA_FK FOREIGN KEY (ID_COMPETENCIA) REFERENCES COMPETENCIA(ID_COMPETENCIA),
|
|
CONSTRAINT PARTICIPAR_COMPETENCIA_ATLETA_FK FOREIGN KEY (ID_ATLETA) REFERENCES ATLETA(ID_ATLETA)
|
|
);
|
|
|
|
CREATE TABLE PARTICIPAR_PRECOMPETENCIA(
|
|
ID_PRECOMPETENCIA NUMBER,
|
|
ID_ATLETA NUMBER,
|
|
PUNTAJE NUMBER,
|
|
FECHA DATE,
|
|
CONSTRAINT PARTICIPAR_PRECOMPETENCIA_PK PRIMARY KEY (ID_PRECOMPETENCIA, ID_ATLETA, FECHA),
|
|
CONSTRAINT PARTICIPAR_PRECOMPETENCIA_PRECOMPETENCIA_FK FOREIGN KEY (ID_PRECOMPETENCIA) REFERENCES PRECOMPETENCIA(ID_PRECOMPETENCIA),
|
|
CONSTRAINT PARTICIPAR_PRECOMPETENCIA_ATLETA_FK FOREIGN KEY (ID_ATLETA) REFERENCES ATLETA(ID_ATLETA)
|
|
);
|