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 > foreign key

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-14-12, 00:20
randhir randhir is offline
Registered User
 
Join Date: Jul 2012
Posts: 1
foreign key

table1: student
attributes: name , roll, dob
primary key: roll


table2: info
attributes : name , age;
foreign key : name(student)

I want to enter values in student table and info table would automatically
update through student table.
is it possible. if yes, then how ?
Reply With Quote
  #2 (permalink)  
Old 07-14-12, 02:06
papadi papadi is offline
Registered User
 
Join Date: Oct 2009
Location: 221B Baker St.
Posts: 487
Depending on what you really want to do, you may be able to do this using a trigger. . .

What do you want automatically updated?
Reply With Quote
  #3 (permalink)  
Old 07-14-12, 10:23
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 480
the second table is redundant as you have their name in the first table and age can be calculated from the dob in the first table.
Reply With Quote
  #4 (permalink)  
Old 07-14-12, 20:34
papadi papadi is offline
Registered User
 
Join Date: Oct 2009
Location: 221B Baker St.
Posts: 487
Do you want the current age (runtime) or the age when the data was inserted?

And yes, it is best to NOT store data that can be derived at run-time (i.e. fixed data like the difference between to stored dates).
Reply With Quote
Reply

Tags
foreign key, reference, referential integrity, update another database

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