Results 1 to 4 of 4

Thread: foreign key

  1. #1
    Join Date
    Jul 2012
    Posts
    1

    Unanswered: 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 ?

  2. #2
    Join Date
    Oct 2009
    Location
    221B Baker St.
    Posts
    486
    Depending on what you really want to do, you may be able to do this using a trigger. . .

    What do you want automatically updated?

  3. #3
    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.

  4. #4
    Join Date
    Oct 2009
    Location
    221B Baker St.
    Posts
    486
    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).

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •