Advertisement
Metziop

Untitled

Aug 26th, 2020 (edited)
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.32 KB | None | 0 0
  1. CREATE DATABASE `bdfutbol`
  2.     CREATE TABLE `equipo` (
  3.   `id_equipo` int NOT NULL,
  4.   `nombre_equipo` varchar(45) NOT NULL,
  5.   `ciudad` varchar(45) NOT NULL,
  6.   `web_oficial` varchar(45) DEFAULT NULL,
  7.   `Puntos` int DEFAULT NULL,
  8.   PRIMARY KEY (`id_equipo`)
  9. )
  10.  
  11.     CREATE TABLE `jugador` (
  12.   `id_jugador` int NOT NULL,
  13.   `nombre` varchar(45) NOT NULL,
  14.   `apellido` varchar(45) NOT NULL,
  15.   `id_capitan` int NOT NULL,
  16.   `posicion` int NOT NULL,
  17.   `fecha_alta` datetime NOT NULL,
  18.   `salario_bruto` int NOT NULL,
  19.   `id_equipo` int NOT NULL,
  20.   PRIMARY KEY (`id_jugador`,`id_capitan`),
  21.   KEY `equipo/jugador_idx` (`id_equipo`),
  22.   CONSTRAINT `equipo/jugador` FOREIGN KEY (`id_equipo`) REFERENCES `equipo` (`id_equipo`)
  23. )
  24.  CREATE TABLE `partido` (
  25.   `evisitante` int NOT NULL,
  26.   `elocal` int NOT NULL,
  27.   `resultado` varchar(45) NOT NULL,
  28.   `fecha` datetime NOT NULL,
  29.   `arbitro` int NOT NULL,
  30.   `id_equipo` int NOT NULL,
  31.   KEY `partido/equipo_idx` (`id_equipo`),
  32.   KEY `partido/equipovis_idx` (`evisitante`),
  33.   KEY `partido/equipoloc_idx` (`elocal`),
  34.   CONSTRAINT `partido/equipo` FOREIGN KEY (`id_equipo`) REFERENCES `equipo` (`id_equipo`),
  35.   CONSTRAINT `partido/equipoloc` FOREIGN KEY (`elocal`) REFERENCES `equipo` (`id_equipo`),
  36.   CONSTRAINT `partido/equipovis` FOREIGN KEY (`evisitante`) REFERENCES `equipo` (`id_equipo`)
  37. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement