If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > DBDesigner and FKindex?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-23-09, 10:57
docc docc is offline
Registered User
 
Join Date: Oct 2009
Posts: 2
Post DBDesigner and FKindex?

Im using DBDesigner and I can't figure out what is the funcionality with FKindexes?

For example, I have a table "ajovuoro" (im sorry the names are in finnish)
CREATE TABLE Ajovuoro (
idAjovuoro INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
Auto_Rekisterinumero VARCHAR(20) NOT NULL,
Kuljettaja_Hetu VARCHAR(20) NOT NULL,
paivamaara DATE NULL,
alkamisaika TIME NULL,
loppumisaika TIME NULL,
PRIMARY KEY(idAjovuoro, Auto_Rekisterinumero, Kuljettaja_Hetu),
INDEX Ajovuoro_FKIndex1(Auto_Rekisterinumero),
INDEX Ajovuoro_FKIndex2(Kuljettaja_Hetu)
);

And i have putted relations to Auto and Rekisterinumero. But why the DBD is making fields(when generating the MySQL code) INDEX Ajuovuoro_FKindex...and...FKindex2, can i just delete those. And when i want to join tables I will just do it when making MySQL queries? What for the program is making INDEX systems?

And why the code generator is putting tree primary keys? Should i just not to make relations becouse mysql code generator is making stupid staff if I make relations between the tables.
Reply With Quote
  #2 (permalink)  
Old 10-23-09, 13:13
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by docc
Im using DBDesigner and I can't figure out what is the funcionality with FKindexes?
this is your first experience with foreign keys? perhaps you should take a tutorial

something went wrong with your PK, it should not be 3 columns in your case, just the first one, the auto_increment

the INDEXes generated by the tool are correct, given that those columns would be the foreign keys to the other tables

however, in recent releases of mysql, these foreign key indexes are created by mysql automatically when the foreign key is declared

i didn't see the actual FK definitions in your CREATE TABLE statement so i assume it is in a subsequent ALTER TABLE statement?

as for your last question, yes you should make relationships (declare primary and foreign keys) -- most definitely, yes

whether you use a tool such as a gui designer, or whether you write SQL by hand, you should make those relationships

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 10-24-09, 11:35
docc docc is offline
Registered User
 
Join Date: Oct 2009
Posts: 2
Smile

Quote:
Originally Posted by r937
this is your first experience with foreign keys? perhaps you should take a tutorial
Correct! I havent worked with foreign keys and maybe I'm gonna look for the turorial right now - last time when I studied databases it was in university and there we were teached that you just join the tables in queries when you want to connect tables.

table Car:
carId(primary key)
color: blaab..blaa

table driver:
driverId(primary key)
carId(relation to the car which car is the driver using)
blaa...blaa

And when I would like to find out which cars are drivers driving, I have to just make query like this:

Select * from car, driver where driver.carId = car.carID

(and relations were just made to understand better about which tables can be joinded together and how. For sure every one but the model of relations were just made for making better queries.) None of the relations were written in the SQL code.

But thanks for advising me, Im gonna look for tutorial first about foreing keys and then read your answer once again.

EDIT: actually, when I looked a tutorial, this driver.carId is working like a foreign key, correct? But still i cant understand why the DBDesigner is making it so complicated by using those index staff and putting tree primarykeys.

Last edited by docc; 10-24-09 at 11:44.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On