SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Location
    Florida
    Posts
    58
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    A couple quick sql questions joins - cascade - foreign keys etc

    Although I usually write sql statements everyday and consider myself to do fairly well with joins,unions etc. I still run into things alot that I have to "look up" and find out what they are doing. Recently I ran into a cascade function that deleted all of a records siblings when a single parent record was deleted which is un doubtedly awesome. But that has just led me to thinking if there are more possibilities that i am missing.

    The first question would be "Is their a way to automatically join a table?"

    for instance if I had 1 table that was only textslugs and ids, can i add a constraint to another table with a foreign key or whatever to automatically fetch the text its textId corresponds to?

    And with the same table scenario, can I insert records into a table and use foreign keys or constraints or whatever to automatically update other tables;

    I am just looking for possibilitys and possibly pointed in the right direction towards either one of the above actions.

    Sorry for using any of the wrong terminoligy or not wording things properly, with all of the things google has taught me over the years communicating well wasnt one of them.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by JamesKenny View Post
    ...can i add a constraint to another table with a foreign key or whatever to automatically fetch the text its textId corresponds to?
    no, sorry -- except if you "pre-join" them with a view that you define

    Quote Originally Posted by JamesKenny View Post
    ...And with the same table scenario, can I insert records into a table and use foreign keys or constraints or whatever to automatically update other tables;
    no, sorry -- except if you write a trigger
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Location
    Florida
    Posts
    58
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)


    thank you though


Tags for this Thread

Bookmarks

Posting Permissions

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