clear markdown compare help best fiddles feedback dbanow.uk
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2805426 fiddles created (40855 in the last week).

CREATE TABLE `author1` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `author_type` char(1) NOT NULL, -- other fields PRIMARY KEY (`id`), UNIQUE KEY `author_UN` (`id`,`author_type`) USING BTREE, CONSTRAINT `author_CHECK_type` CHECK (`author_type` in ('P','C')) );
 hidden batch(es)


CREATE TABLE `author_personal1` ( `id` int(10) unsigned NOT NULL, `surname` varchar(30) DEFAULT NULL, `name` varchar(30) DEFAULT NULL, -- other fields `author_type` char(1) GENERATED ALWAYS AS ('P') VIRTUAL, PRIMARY KEY (`id`), KEY `author_personal_FK` (`id`,`author_type`), CONSTRAINT `author_personal_FK` FOREIGN KEY (`id`, `author_type`) REFERENCES `author1` (`id`, `author_type`) ON DELETE CASCADE );
 hidden batch(es)


CREATE TABLE `work_authors1` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `work_id` int(10) unsigned NOT NULL, `author_id` int(10) unsigned NOT NULL, -- other fields PRIMARY KEY (`id`), KEY `work_authors_FK` (`work_id`), KEY `work_authors_FK_author` (`author_id`) USING BTREE, CONSTRAINT `work_authors_FK_author` FOREIGN KEY (`author_id`) REFERENCES `author1` (`id`) ON UPDATE CASCADE );
 hidden batch(es)


select table_name, constraint_name, referenced_table_name, unique_constraint_name from information_schema.referential_constraints;
table_name constraint_name referenced_table_name unique_constraint_name
album fk_album_artist artist PRIMARY
author_personal1 author_personal_FK author1 author_UN
work_authors1 work_authors_FK_author author1 PRIMARY
 hidden batch(es)