Advertisement
ZarTek-CREOLE

Untitled

Apr 4th, 2023
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 2.00 KB | None | 0 0
  1. CREATE DATABASE IF NOT EXISTS rencontre;
  2. USE rencontre;
  3.  
  4. CREATE TABLE users (
  5.     id INT AUTO_INCREMENT PRIMARY KEY,
  6.     username VARCHAR(50) UNIQUE NOT NULL,
  7.     email VARCHAR(100) UNIQUE NOT NULL,
  8.     password VARCHAR(255) NOT NULL,
  9.     first_name VARCHAR(50),
  10.     last_name VARCHAR(50),
  11.     birthdate DATE,
  12.     gender ENUM('homme', 'femme', 'non-binaire', 'autre'),
  13.     sexual_orientation ENUM('hétérosexuel', 'homosexuel', 'bisexuel', 'autre'),
  14.     location VARCHAR(255),
  15.     profile_photo VARCHAR(255),
  16.     bio TEXT,
  17.     looking_for ENUM('amitié', 'amour', 'aventure', 'autre'),
  18.     last_active TIMESTAMP,
  19.     account_status ENUM('actif', 'suspendu', 'banni') DEFAULT 'actif'
  20. );
  21.  
  22. CREATE TABLE interests (
  23.     id INT AUTO_INCREMENT PRIMARY KEY,
  24.     interest_name VARCHAR(100) UNIQUE NOT NULL
  25. );
  26.  
  27. CREATE TABLE user_interests (
  28.     user_id INT,
  29.     interest_id INT,
  30.     FOREIGN KEY (user_id) REFERENCES users(id),
  31.     FOREIGN KEY (interest_id) REFERENCES interests(id),
  32.     UNIQUE (user_id, interest_id)
  33. );
  34.  
  35. CREATE TABLE photos (
  36.     id INT AUTO_INCREMENT PRIMARY KEY,
  37.     user_id INT,
  38.     photo_url VARCHAR(255) NOT NULL,
  39.     caption VARCHAR(255),
  40.     upload_date TIMESTAMP,
  41.     FOREIGN KEY (user_id) REFERENCES users(id)
  42. );
  43.  
  44. CREATE TABLE messages (
  45.     id INT AUTO_INCREMENT PRIMARY KEY,
  46.     sender_id INT,
  47.     receiver_id INT,
  48.     content TEXT NOT NULL,
  49.     sent_date TIMESTAMP,
  50.     read_date TIMESTAMP,
  51.     FOREIGN KEY (sender_id) REFERENCES users(id),
  52.     FOREIGN KEY (receiver_id) REFERENCES users(id)
  53. );
  54.  
  55. CREATE TABLE likes (
  56.     user_id INT,
  57.     liked_user_id INT,
  58.     like_date TIMESTAMP,
  59.     FOREIGN KEY (user_id) REFERENCES users(id),
  60.     FOREIGN KEY (liked_user_id) REFERENCES users(id),
  61.     UNIQUE (user_id, liked_user_id)
  62. );
  63.  
  64. CREATE TABLE matches (
  65.     user_id INT,
  66.     matched_user_id INT,
  67.     match_date TIMESTAMP,
  68.     FOREIGN KEY (user_id) REFERENCES users(id),
  69.     FOREIGN KEY (matched_user_id) REFERENCES users(id),
  70.     UNIQUE (user_id, matched_user_id)
  71. );
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement