mysql - it is possible to reference one column as multiple foreign keys -
I have some tables, and I want to refer to a column from the PDF table in several other tables.
For example, if the PDF table It tells me: PDF has 3 car wheel products, and up to 1 car template header; I have written the code but do not work properly: Is it possible to create it? number That is, you did not create a foreign key obstacle in this way Can. You can use a foreign key without any foreign key constraints. All foreign keys, the price of another table (or another record in the same table), is the primary key, which can be used in use. In fact, you can refer to fields other than the primary key, if you need to, then use the value to join. However, a foreign key tells the barrier to apply the database to each foreign key, the value in a table, with a record in the referenced table, because it is the primary key to ensure that PDF In the table, every foreign key will not work for you as a primary key in all four tabs . So go ahead and use the fields in the context of other records, but do not just make any foreign key obstacles. select output looks like this:
ITEM_TYPE ITEM_ID QUANTITY 1 23 3 2 12 1
create tab 'pdf_created` (`id` INT (10) unsigned NULL unique AUTO_INCREMENT,` pdf_id` INT (10) nOT NULL, `item_type` INT (3) unsigned nOT NULL,` item_id` INT (10) unsigned nOT NULL, `quantity` INT (3) not NULL, pRIMARY KEY (` Id`), key `FK_pdf_id` (` pdf_id`), Badha` FK_pdf_id` foreign key ( `pdf_id`) to Sndrb` pdf` (` id`), Kunji` FK_item_type` ( `item_type`), Badha` FK_item_type` foreign key (` item_type `) Referred` item` (`id`) to CASCADE on the update CASCADE, the key Let `FK_item_id` (` item_id`), Badha` FK_item_id` foreign key ( `item_id`) to Sndrb` product` (` Aidi`) update CADE on Daily Cascade CAS barrier `FK_item_id` foreign key (` item_id`) reference `Service` (` Id`) to update removes the CASCADE CASCADE, barrier `FK_item_id` Cascade Dislet foreign key (` item_id`) rEFERENCES `Kasaded updated on Header` (` Id`)) engine = Innodibi default charge = UTF8; Create table `header` (` id` INT (10) unsigned NULL unique AUTO_INCREMENT, `title` VARCHAR (255),` desc` VARCHAR (65535), primary key (`id`) engine = InnoDB default charset = UTF8 ; Tab 'service' ( `Aidi` Aianti (10) has not been unlocked, unlock tap Ananyuk Otongrement,` No. 'VARCHAR (65535) NULL, `Kimt` Disiaimel (5,2) NULL,` active' INT (1) Null, primary key (`id`)) engine = indodie default charge = utf 8; Table `product` (` id` INT (10) unsigned NOT NULL unique AUTO_INCREMENT, `category_id` INT (3) unsigned NOT NULL,` symbol` VARCHAR (255), `desc` VARCHAR (65535),` price` create decimal (5,2) Faucet, Primary key (`ID`)) Engine = IndodieBee default charge = UTF8;
Comments
Post a Comment