CREATE TABLE users( "id" serial primary key not null, "email" varchar unique, "username" varchar unique, "password" varchar, "avatar_picture" varchar, "google_sign_in_payload" varchar, "banned_at" timestamp, "banned_until" timestamp, "is_admin" boolean, "is_critics" boolean, "is_verified" boolean, "ipv4_address" varchar(15) not null, "social_media" jsonb, "created_at" timestamp default(now()), "updated_at" timestamp default(now()) ); CREATE TABLE regions( "id" serial primary key not null, "region_name" varchar, "created_at" timestamp default(now()), "updated_at" timestamp default(now()) ); CREATE TABLE provinces( "id" serial primary key not null, "province_name" varchar, "region_id" smallint references "regions"("id") not null, "created_at" timestamp default(now()), "updated_at" timestamp default(now()) ); CREATE TABLE regencies( "id" serial primary key not null, "regency_name" varchar, "province_id" smallint references "provinces"("id") not null, "created_at" timestamp default(now()), "updated_at" timestamp default(now()) ); CREATE TABLE locations( "id" serial primary key not null, "address" varchar, "name" varchar, "google_maps_link" varchar, "submitted_by" integer references "users"("id") not null, "total_visited" integer, "thumbnail" varchar, "regency_id" smallint references "regencies"("id") not null, "is_deleted" boolean, "created_at" timestamp default(now()), "updated_at" timestamp default(now()) ); CREATE TABLE tags ( "id" serial primary key not null, "name" varchar(50) not null, "target_id" integer, "tags_type" varchar(20), "created_at" timestamp default(now()), "updated_at" timestamp default(now()) ); CREATE TABLE location_images ( "id" serial primary key not null, "url" varchar not null, "location_id" integer references "locations"("id") not null, "uploaded_by" integer references "users"("id"), "created_at" timestamp default(now()), "updated_at" timestamp default(now()) ); CREATE TABLE reviews ( "id" serial primary key not null, "submitted_by" integer references "users"("id") not null, "comments" text not null, "score" smallint not null, "is_hided" boolean, -- if comments violate TOS just hide the reviews "location_id" integer references "locations"("id") not null, "created_at" timestamp default(now()), "updated_at" timestamp default(now()) );