CREATE TABLE "examples" (
	"id" serial PRIMARY KEY NOT NULL,
	"word_id" serial NOT NULL,
	"hindi" text NOT NULL,
	"english" text NOT NULL,
	"note" text
);
--> statement-breakpoint
CREATE TABLE "see_also" (
	"id" serial PRIMARY KEY NOT NULL,
	"word_id" serial NOT NULL,
	"reference" text NOT NULL,
	"note" text
);
--> statement-breakpoint
CREATE TABLE "tags" (
	"id" serial PRIMARY KEY NOT NULL,
	"name" text NOT NULL,
	"description" text,
	CONSTRAINT "tags_name_unique" UNIQUE("name")
);
--> statement-breakpoint
CREATE TABLE "word_tags" (
	"id" serial PRIMARY KEY NOT NULL,
	"word_id" serial NOT NULL,
	"tag_id" serial NOT NULL
);
--> statement-breakpoint
CREATE TABLE "words" (
	"id" serial PRIMARY KEY NOT NULL,
	"hindi" text NOT NULL,
	"english" text NOT NULL,
	"type" text,
	"gender" text,
	"note" text,
	"created_at" timestamp DEFAULT now() NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "examples" ADD CONSTRAINT "examples_word_id_words_id_fk" FOREIGN KEY ("word_id") REFERENCES "public"."words"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "see_also" ADD CONSTRAINT "see_also_word_id_words_id_fk" FOREIGN KEY ("word_id") REFERENCES "public"."words"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "word_tags" ADD CONSTRAINT "word_tags_word_id_words_id_fk" FOREIGN KEY ("word_id") REFERENCES "public"."words"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "word_tags" ADD CONSTRAINT "word_tags_tag_id_tags_id_fk" FOREIGN KEY ("tag_id") REFERENCES "public"."tags"("id") ON DELETE no action ON UPDATE no action;