-- Create cuisines table
CREATE TABLE IF NOT EXISTS cuisines (
  id SERIAL PRIMARY KEY,
  name VARCHAR(255) NOT NULL UNIQUE
);

-- Create restaurant_cuisines linking table for many-to-many relationship
CREATE TABLE IF NOT EXISTS restaurant_cuisines (
  restaurant_id INT NOT NULL,
  cuisine_id INT NOT NULL,
  PRIMARY KEY (restaurant_id, cuisine_id),
  CONSTRAINT fk_restaurant
    FOREIGN KEY(restaurant_id)
    REFERENCES restaurants(id)
    ON DELETE CASCADE,
  CONSTRAINT fk_cuisine
    FOREIGN KEY(cuisine_id)
    REFERENCES cuisines(id)
    ON DELETE CASCADE
);
