SQL

  • Samith C

    Mr or Mrs. 500

    Points: 519

    Comments posted to this topic are about the item SQL

    [font="Verdana"] There is no Wrong time to do a Right thing 🙂 [/font]

  • Dineshbabu

    Hall of Fame

    Points: 3220

    We can delete a row in primary table if CASCADE option is chosen On DELETE rite?

    --
    Dineshbabu
    Desire to learn new things..

  • Kingston Dhasian

    SSCoach

    Points: 19794

    dineshbabus (11/29/2012)


    We can delete a row in primary table if CASCADE option is chosen On DELETE rite?

    Yes. You can delete a row in the PRIMARY table if the CASCADE DELETE option is set.

    I got this right because the question said there are 2 incorrect answers and I assumed this to be one of them as 3 of the options are definitely correct


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • Dineshbabu

    Hall of Fame

    Points: 3220

    wat does this mean "Breaking of relationships is prevented once referential integrity on a database is enforced".

    --
    Dineshbabu
    Desire to learn new things..

  • Koen Verbeeck

    SSC Guru

    Points: 258965

    Got it wrong because you can update or delete rows in the primary tables if you specify ON CASCADE options.

    Next time do more homework please.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Dineshbabu

    Hall of Fame

    Points: 3220

    thanks..

    pls xplain wat does breaking of relationship means?

    --
    Dineshbabu
    Desire to learn new things..

  • Kingston Dhasian

    SSCoach

    Points: 19794

    dineshbabus (11/30/2012)


    thanks..

    pls xplain wat does breaking of relationship means?

    Breaking of relationship means any action( INSERT, UPDATE or DELETE ) that results in an entry in FOREIGN KEY table that does not have a corresponding primary key in the PRIMARY KEY table


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • This was removed by the editor as SPAM

  • Lokesh Vij

    SSChampion

    Points: 10836

    Stewart "Arturius" Campbell (11/30/2012)


    Koen Verbeeck (11/30/2012)


    Got it wrong because you can update or delete rows in the primary tables if you specify ON CASCADE options.

    Next time do more homework please.

    +1

    +1

    I think most of us have got this wrong due to this statement 🙂

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • Keld Laursen (SEGES)

    SSC Eights!

    Points: 843

    Hmm, are the conditions correct?

    The statements were:

    Can’t update secondary table’s foreign key if there is no related row in primary table.

    Hmm, the reference material states that I can NOT update the foreign key unless it is to a new valid primary key value OR i set the foreign key to NULL. The latter is only valid if I allow nulls on the column

    If I allow nulls the above statement is invalid.

    Breaking of relationships is prevented once referential integrity on a database is enforced.

    If the above statement is invalid and I can set the foreign key to NULL, am I not breaking the referential integrity of these? Thus making this statement invalid? Unless of course you declare referential integrity to be "pointing to a valid primary or nothing".

    Can delete a row from primary table if there are related rows in secondary table.

    If statement 1 can be modified between true and false by changing settings (foreign key nullable), can this not be made true by allowing DELETE cascade?

    Can’t update primary table’s primary key if row being modified has related rows in secondary table.

    Again: Update cascade should be the difference between this statement being false or true.

    Can insert a new row in secondary table if there are not related rows in primary table.

    And again the nullability of the foreign key column defines whether this is wrong or right.

    As far as I can enumerate, then you can make all statements above either true or false. Although perhaps not all at the same time.

    Or where did my reasoning go astray?

    😀

    I mainly got my guess wrong as we routinely disallow NULL on foreign keys and specify UPDATE and DELETE CASCADE options as ON. Which AFAICS will yield #1 and #5 false and 2-4 true.

  • Dineshbabu

    Hall of Fame

    Points: 3220

    I think he is expecting us to think in normal scenario.. We shud not think beyond that..

    --
    Dineshbabu
    Desire to learn new things..

  • Arthur Olcot

    SSCertifiable

    Points: 6008

    Lokesh Vij (11/30/2012)


    Stewart "Arturius" Campbell (11/30/2012)


    Koen Verbeeck (11/30/2012)


    Got it wrong because you can update or delete rows in the primary tables if you specify ON CASCADE options.

    Next time do more homework please.

    +1

    +1

    I think most of us have got this wrong due to this statement 🙂

    +1

    Yep, i've just done exactly the same..

  • Carlo Romagnano

    SSC-Insane

    Points: 21943

    OK, I get it wrong, but I understood that the author does not know the "ON CASCADE" options.

  • This was removed by the editor as SPAM

  • kalyani.k478

    Default port

    Points: 1400

    +1

Viewing 15 posts - 1 through 15 (of 61 total)

You must be logged in to reply to this topic. Login to reply