I have the database table page with the fields contenttype_id and content_id. I want to link a page to a contenttype via contenttype_id and refer to an actual content via content_id. The problem is contents depend on the contenttype_id and are modelled differently, therefore the content_id refers to different tables depending on the contenttype_id.
CREATE TABLE "page"
("id" "INT",
"author" "VARCHAR(45)",
"created" "DATE",
"content_type" "INT",
"content_id" "INT")
CREATE TABLE "contenttype"
("id" "INT",
"name" "VARCHAR(45)")
CREATE TABLE "content_redirect"
("id" "INT",
"url" "VARCHAR(45)")
CREATE TABLE "content_script"
("id" "INT",
"url" "VARCHAR(45)",
"params", "VARCHAR(45)")
CREATE TABLE "content_text"
("id" "INT",
"text" "TEXT")
CREATE TABLE "content_process"
("id" "INT",
"step1" "TEXT",
"step2" "TEXT",
"step3" "TEXT")
CREATE TABLE "content_extprocess"
("id" "INT",
"system_id" "INT",
"process_id" "INT")
How to do that? Or is it already theoretically wrong?