Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. integrity constraint

integrity constraint

Scheduled Pinned Locked Moved Database
tutorialquestion
5 Posts 3 Posters 25 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tara11
    wrote on last edited by
    #1

    For example to transfer the sum of $100 from account 123 to account 456. we want the total number of dollars in accounts 123 and 456 taken together not to change.
    Why it would be unreasonable to declare an integrity constraint to that effect?

    M W 2 Replies Last reply
    0
    • T Tara11

      For example to transfer the sum of $100 from account 123 to account 456. we want the total number of dollars in accounts 123 and 456 taken together not to change.
      Why it would be unreasonable to declare an integrity constraint to that effect?

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      That is what transactions are for, wrap the transfer in a transaction if there is an error roll back the transaction. An after process integrity check is not unreasonable but the correct way is with a transaction.

      Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

      T 1 Reply Last reply
      0
      • M Mycroft Holmes

        That is what transactions are for, wrap the transfer in a transaction if there is an error roll back the transaction. An after process integrity check is not unreasonable but the correct way is with a transaction.

        Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

        T Offline
        T Offline
        Tara11
        wrote on last edited by
        #3

        But the book says it's unreasonable.

        M 1 Reply Last reply
        0
        • T Tara11

          But the book says it's unreasonable.

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          The book should say it is incorrect or redundant and should recommend using a transaction. All books are not 100% correct all the time.

          Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

          1 Reply Last reply
          0
          • T Tara11

            For example to transfer the sum of $100 from account 123 to account 456. we want the total number of dollars in accounts 123 and 456 taken together not to change.
            Why it would be unreasonable to declare an integrity constraint to that effect?

            W Offline
            W Offline
            Wendelius
            wrote on last edited by
            #5

            Tara11 wrote:

            Why it would be unreasonable to declare an integrity constraint to that effect?

            Mainly because integrity constraint operate on row-basis. Transactions then again ensure that the operation is completed as a whole even when multiple commands are affected. But neither of these guarantee that the total sum is unaffected when money is transferred. If this would be a single table operation, a trigger could be utilized to do that check.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups