Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get Foreign Keys to AUTO receive Primary key Value???

Status
Not open for further replies.

snekone

Technical User
Feb 25, 2002
9
0
0
NL
Hi, I am an amateur database contructor, and have quite some experience using PowerBuilder with a Sybase SQL Anywhere server/database. PowerBuilder has a nice GUI to set everything and it wasn't that hard to get Foreign Keys (FK) to have the same values as the referenced Primary Keys (PK) automatically...

Now, in MySQL I have NO IDEA of how to do this! Can this actually be done using MySQL "script" or will it have to be done in another language like PHP? I can figure out how to send variables etc with PHP but there must be some way that the DBMS can do this by itself, right? I mean, what point is it building a huge database with some really advanced PK and FK links if I still have to do most of the really handy stuff in another language? Then I might as well not use FK's...

Does it have to do with ON UPDATE settings in the CREATE TABLE query? This wouldn't really seem logical to me since I don't consider INSERT INTO an ON UPDATE command... But maybe that's my problem ;)

So, if anyone could tell me the answer I would be really greatful!! (I'm building an Intranet for a company as a school-project in PHP/MySQL)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top