import { Snippet } from "@/components/Snippet";

const sqlExampleSnippets = [
	{
		name: "Exemple de LDD",
		codeLanguage: "sql",
		withLineNumbers: true,
		code: `CREATE TABLE "table_1" (
	"id_table_1" INTEGER NOT NULL UNIQUE,
	"column_2" VARCHAR(50) NOT NULL,
	"column_3" VARCHAR(50) NOT NULL,
	"table_3_id" INTEGER NOT NULL,
	PRIMARY KEY("id_table_1")
);
CREATE INDEX "table_1_index_0"
ON "table_1" ("id_table_3");

CREATE TABLE "table_3" (
	"id_table_3" INTEGER NOT NULL UNIQUE GENERATED BY DEFAULT AS IDENTITY,
	"column_2" VARCHAR(50) NOT NULL,
	"column_3" VARCHAR(50) NOT NULL,
	"table_3_id" INTEGER,
	PRIMARY KEY("id_table_3")
);
CREATE INDEX "table_3_index_0"
ON "table_3" ("id_table_3");

CREATE TABLE "table_2" (
	"id_table_2" INTEGER NOT NULL UNIQUE GENERATED BY DEFAULT AS IDENTITY,
	"column_2" VARCHAR(50) NOT NULL,
	"column_3" VARCHAR(50) NOT NULL,
	PRIMARY KEY("id_table_2")
);
CREATE INDEX "table_2_index_0"
ON "table_2" ("id_table_2");

CREATE TABLE "table_1_contains_table_2" (
	"table_1_id" INTEGER NOT NULL,
	"table_2_id" INTEGER NOT NULL,
	PRIMARY KEY("table_1_id", "table_2_id")
);
CREATE UNIQUE INDEX "table_1_contains_table_2_index_0"
ON "table_1_contains_table_2" ("table_1_id", "table_2_id");

ALTER TABLE "table_1"
ADD FOREIGN KEY("table_3_id") REFERENCES "table_3"("id_table_3")
ON UPDATE NO ACTION ON DELETE NO ACTION;

ALTER TABLE "table_3"
ADD FOREIGN KEY("id_table_3") REFERENCES "table_3"("table_3_id")
ON UPDATE NO ACTION ON DELETE NO ACTION;

ALTER TABLE "table_1"
ADD FOREIGN KEY("id_table_1") REFERENCES "table_1_contains_table_2"("table_1_id")
ON UPDATE NO ACTION ON DELETE NO ACTION;

ALTER TABLE "table_1_contains_table_2"
ADD FOREIGN KEY("table_2_id") REFERENCES "table_2"("id_table_2")
ON UPDATE NO ACTION ON DELETE NO ACTION;`,
	},
];

export default {
	sqlExample: () => <Snippet snippets={sqlExampleSnippets} />,
};
