MySQL Forums
Forum List  »  German

Hilfe: Fremdschlüssel-Verständnis
Posted by: Sebastian Kahl
Date: December 08, 2009 07:16AM

Hallo,
kann mir jemand bitte erklären, wie das mit den Fremdschlüsseln abläuft. Ich arbeite mit MySQLworkbench und dort gibt es die Bezeichnungen "referencing table" und "referenced table", wie übersetzt man das denn eindeutig?
Und dann würde ich noch gerne wissen, auf was sich ein Constraint genau auswirkt.
Bsp:

CREATE TABLE IF NOT EXISTS `invtest`.`hardware_types` (
`id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT ,
`description` VARCHAR(50) NOT NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB;


CREATE TABLE IF NOT EXISTS `invtest`.`hardware_units` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`hardware_types_id` SMALLINT UNSIGNED NOT NULL ,
`inactive` TINYINT(1) NOT NULL ,
`serial_number` VARCHAR(50) NULL ,
`ip` VARCHAR(50) NULL ,
`purchase_date` DATE NULL ,
PRIMARY KEY (`id`) ,
INDEX `fk_units_types` (`hardware_types_id` ASC) ,
CONSTRAINT `fk_units_types`
FOREIGN KEY (`hardware_types_id` )
REFERENCES `invtest`.`hardware_types` (`id` )
ON DELETE NO ACTION
ON UPDATE CASCADE,
ENGINE = InnoDB;


Vielen Dank, falls sich jemand die Mühe macht.

Options: ReplyQuote


Subject
Views
Written By
Posted
Hilfe: Fremdschlüssel-Verständnis
6183
December 08, 2009 07:16AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.