SHARE
TWEET

Untitled

a guest Jul 16th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE usuarios (
  2.     id INT NOT NULL UNIQUE AUTO_INCREMENT,
  3.     nombre VARCHAR(25) UNIQUE NOT NULL,
  4.     email VARCHAR(255) UNIQUE NOT NULL,
  5.     password VARCHAR(255) NOT NULL,
  6.     fecha_registro DATETIME NOT NULL,
  7.     activo TINYINT NOT NULL,
  8.     PRIMARY KEY(id)
  9. );
  10. CREATE TABLE entradas (
  11.     id INT NOT NULL UNIQUE AUTO_INCREMENT,
  12.     autor_id INT NOT NULL,
  13.     titulo VARCHAR(255) NOT NULL UNIQUE,
  14.     texto TEXT CHARACTER SET utf8 NOT NULL,
  15.     fecha DATETIME NOT NULL,
  16.     activa TINYINT NOT NULL,  
  17.     PRIMARY KEY(id),  
  18.         FOREIGN KEY(autor_id)
  19.             REFERENCES usuarios(id)
  20.                 ON UPDATE CASCADE
  21.                 ON DELETE RESTRICT
  22. );
  23. CREATE TABLE comentarios (
  24.     id INT NOT NULL UNIQUE AUTO_INCREMENT,
  25.     autor_id INT NOT NULL,
  26.     entrada_id INT NOT NULL,
  27.     titulo VARCHAR(255) NOT NULL,
  28.     texto TEXT CHARACTER SET utf8 NOT NULL,
  29.     fecha DATETIME NOT NULL,  
  30.     PRIMARY KEY(id),
  31.      FOREIGN KEY(autor_id)
  32.         REFERENCES usuarios(id)
  33.             ON UPDATE CASCADE
  34.             ON DELETE RESTRICT,
  35.         FOREIGN KEY(entrada_id)
  36.         REFERENCES entradas(id)
  37.             ON UPDATE CASCADE
  38.             ON DELETE RESTRICT
  39. );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top