Advertisement
Al0rse

Test TalentPitch

Jan 19th, 2024
1,527
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.67 KB | None | 0 0
  1. CREATE TABLE users (
  2.     id INT PRIMARY KEY,
  3.     name VARCHAR(255),
  4.     email VARCHAR(255) UNIQUE,
  5.     image_path VARCHAR(255) NULL,
  6.     created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  7.     updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  8. );
  9.  
  10. CREATE TABLE challenges (
  11.     id INT PRIMARY KEY,
  12.     title VARCHAR(255),
  13.     description TEXT,
  14.     difficulty INT,
  15.     user_id INT,
  16.     FOREIGN KEY (user_id) REFERENCES users(id),
  17.     created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  18.     updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  19. );
  20.  
  21. CREATE TABLE companies (
  22.     id INT PRIMARY KEY,
  23.     name VARCHAR(255),
  24.     image_path VARCHAR(255) NULL,
  25.     location VARCHAR(255),
  26.     industry VARCHAR(255),
  27.     user_id INT,
  28.     FOREIGN KEY (user_id) REFERENCES users(id),
  29.     created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  30.     updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  31. );
  32.  
  33. CREATE TABLE programs (
  34.     id INT PRIMARY KEY,
  35.     title VARCHAR(255),
  36.     description TEXT,
  37.     start_date DATE,
  38.     end_date DATE,
  39.     user_id INT,
  40.     FOREIGN KEY (user_id) REFERENCES users(id),
  41.     created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  42.     updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  43. );
  44.  
  45. CREATE TABLE program_participants (
  46.     id INT PRIMARY KEY,
  47.     program_id INT,
  48.     entity_type VARCHAR(50), -- Indicar el tipo de entidad: 'user', 'challenge', 'company'
  49.     entity_id INT, -- ID de la entidad participante
  50.     FOREIGN KEY (program_id) REFERENCES programs(id),
  51.     FOREIGN KEY (entity_id, entity_type) REFERENCES users(id, 'user') -- Ajustar para otras entidades
  52. );
  53.  
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement