Skip to content

Instantly share code, notes, and snippets.

@dineshsonachalam
Last active November 25, 2021 17:27
Show Gist options
  • Save dineshsonachalam/cd0d492097c367a8162453f5a991711e to your computer and use it in GitHub Desktop.
Save dineshsonachalam/cd0d492097c367a8162453f5a991711e to your computer and use it in GitHub Desktop.
image_tagging_system.sql
CREATE TABLE IF NOT EXISTS app_user (
user_id SERIAL PRIMARY KEY,
email VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL
);
CREATE TABLE IF NOT EXISTS image (
image_id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
created_by INT NOT NULL references app_user(user_id)
);
CREATE TABLE IF NOT EXISTS tag (
tag_id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL
);
CREATE TABLE IF NOT EXISTS tag_map (
tag_map_id SERIAL PRIMARY KEY,
image_id INT NOT NULL references image(image_id),
tag_id INT NOT NULL references tag(tag_id)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment