Sasa Posted June 26, 2009 Report Share Posted June 26, 2009 Kas tas ir tāds 'Links to', kas ir dažām manām tabulām? PS. bildi nesanāk pievienot servers saka: "Error The server returned an error during upload"! Quote Link to comment Share on other sites More sharing options...
bubu Posted June 26, 2009 Report Share Posted June 26, 2009 Lauku jaunu esi pieliecs tabulām vai kā? Nu ja nevajag tādu lauku, tad dzēs to ārā (ALTER TABLE x DROP COLUMN `Links to`) Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted June 26, 2009 Report Share Posted June 26, 2009 Varbūt, ka tas ir saistīts ar to, ka tabulām ir InnoDB tips un tās tabulas, kuras "links to" izmanto kā Foreign Key to tabulu, uz kuru tās "links to" :) http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html Quote Link to comment Share on other sites More sharing options...
Sasa Posted June 26, 2009 Author Report Share Posted June 26, 2009 Kaut kā šādi izskatās! Bažijos par Links to (product -> ID), jo nezinu kas tas tāds. Field Type Null Default Links to Comments MIME accs_id bigint(20) No product_id bigint(20) Yes NULL product -> ID drillQty bigint(20) Yes NULL fas2 double(20,20) Yes NULL korp08 double(20,20) Yes NULL fas04 double(20,20) Yes NULL fas2fig double(20,20) Yes NULL korp08fig double(20,20) Yes NULL mel double(20,20) Yes NULL picture varchar(200) Yes NULL Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted June 26, 2009 Report Share Posted June 26, 2009 Jup - ProductID ir foreign key uz lauku ID tabulā products Quote Link to comment Share on other sites More sharing options...
Sasa Posted June 26, 2009 Author Report Share Posted June 26, 2009 Un? Uz ko tas norāda? Jā man ir tāda tabula 'product' ar lauku 'ID'. Vot kā man ir man ir product tabula un šai produkt tabulai nāk blakus vēl divas tabulas kurās figurē produkta ID, lai es velāk varētu atrast kas attiecās uz šo produktu, tad lai paliek tie Foreign key ?? Quote Link to comment Share on other sites More sharing options...
bubu Posted June 26, 2009 Report Share Posted June 26, 2009 Tas norāda MySQL'am, ka vērtības product_id referencējas uz ID vērtībām tabulā products. Parasti tas palīdz nodrošināt datubāzes integritāti. Piemēram, dzēšot kādu produkta tabulas ierakstu visi attiecīgi citu tabulu ieraksti, kuri referencējas uz dzēšāmo produktu, arī tiks automātiski dzēsti (vai arī dzēšana tiks aizliegta, atkarībā no ārējās atslēgas uzstādījumiem). Tavu pēdējo jautājumu nesapratu. Kā izselektēt tos produktus? Ar parastu JOIN'u: SELECT x.*, product.* FROM x JOIN products ON x.product_id = product.id Quote Link to comment Share on other sites More sharing options...
Sasa Posted June 26, 2009 Author Report Share Posted June 26, 2009 (edited) Kā no MySQL (Win) izdabūnu manu tabulu struktūru, lai pārādītu kā man tur viss satiasīts? Edited June 26, 2009 by Sasa Quote Link to comment Share on other sites More sharing options...
bubu Posted June 26, 2009 Report Share Posted June 26, 2009 Read The Fine Manual :) http://dev.mysql.com/doc/refman/5.0/en/show-create-table.html vai arī http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html (ar --no-data) Quote Link to comment Share on other sites More sharing options...
Sasa Posted June 26, 2009 Author Report Share Posted June 26, 2009 Tabulas: Product CREATE TABLE `product` ( `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(200) COLLATE utf8_unicode_ci NOT NULL, `description` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM AUTO_INCREMENT=359 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci Details CREATE TABLE `details` ( `det_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `product_id` bigint(20) unsigned NOT NULL, `lenght` bigint(20) unsigned NOT NULL, `mel1` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `abs1` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `width` bigint(20) unsigned NOT NULL, `mel2` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `abs2` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `qtn` bigint(20) unsigned NOT NULL, `type` varchar(10) COLLATE utf8_unicode_ci NOT NULL, `detNr` bigint(20) unsigned NOT NULL, `image` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`det_id`), UNIQUE KEY `det_id` (`det_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci Accessories CREATE TABLE `accessories` ( `accs_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `product_id` bigint(20) unsigned DEFAULT NULL, `drillQty` bigint(20) unsigned DEFAULT NULL, `fas2` double(20,20) DEFAULT NULL, `korp08` double(20,20) DEFAULT NULL, `fas04` double(20,20) DEFAULT NULL, `fas2fig` double(20,20) DEFAULT NULL, `korp08fig` double(20,20) DEFAULT NULL, `mel` double(20,20) DEFAULT NULL, `picture` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`accs_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci Bet te neparādās Foreign key !? MySQL pats izdomāja .. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.