Skip to content

Instantly share code, notes, and snippets.

@stefan-000
Created June 27, 2024 15:59
Show Gist options
  • Save stefan-000/3606327423fcd74fb489907c1ec809b2 to your computer and use it in GitHub Desktop.
Save stefan-000/3606327423fcd74fb489907c1ec809b2 to your computer and use it in GitHub Desktop.
CREATE DATABASE linkedin;
USE linkedin;
CREATE TABLE Users (
id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(255),
last_name VARCHAR(255),
username VARCHAR(255),
password VARCHAR(255)
);
CREATE TABLE Schools (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
type VARCHAR(255),
location VARCHAR(255),
founded_year INT
);
CREATE TABLE Companies (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
industry VARCHAR(255),
location VARCHAR(255)
);
CREATE TABLE Connections (
user_id INT,
connection_id INT,
PRIMARY KEY (user_id, connection_id),
FOREIGN KEY (user_id) REFERENCES Users(id),
FOREIGN KEY (connection_id) REFERENCES Users(id)
);
CREATE TABLE SchoolAffiliations (
user_id INT,
school_id INT,
start_date DATE,
end_date DATE,
degree VARCHAR(255),
PRIMARY KEY (user_id, school_id),
FOREIGN KEY (user_id) REFERENCES Users(id),
FOREIGN KEY (school_id) REFERENCES Schools(id)
);
CREATE TABLE CompanyAffiliations (
user_id INT,
company_id INT,
start_date DATE,
end_date DATE,
title VARCHAR(255),
PRIMARY KEY (user_id, company_id),
FOREIGN KEY (user_id) REFERENCES Users(id),
FOREIGN KEY (company_id) REFERENCES Companies(id)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment