tailieunhanh - Microsoft SQL Server 2005 Express Edition for Dummies phần 6
Brace mình: Bạn đang về để đọc một số thông tin của bạn có thể bị mất toàn vẹn của nó. May mắn thay, bạn có thể tránh được các kịch bản này khó chịu bằng cách đơn giản sử dụng một sự kết hợp toàn vẹn tham chiếu (các phím tiểu học và ngoài nước) và các giao dịch. Cha mẹ và con khác biệt: | 194 Part IV Keeping Your Data Safe from Harm Shocking tales of lost integrity Brace yourself You re about to read several ways that your information can lose its integrity. Fortunately you can avoid each of these unpleasant scenarios by simply employing a combination of referential integrity primary and foreign keys and transactions. Parent and child differences Imagine that your database includes data stored in parent header and child detail tables. Furthermore suppose that you keep a running total of information in the parent table about records in the child table. A good example is customer details name address financial summary in the parent table and customer transactions transaction date amount and so on in the child table. If you re not careful these two tables can get out of sync which might lead to someone looking at data in the parent table to make an incorrect assumption. Orphans Continuing with the preceding example what happens if you intentionally delete a parent record but somehow overlook deleting its related children You re left with the sad prospect of orphaned child records forever doomed to a lonely existence in your database. Partial updates A partial update can happen when all the tables that are supposed to be updated at one time don t actually successfully complete their modifications. The classic example of this problem is a failure when transferring money between savings and checking tables. If the application only reduces the savings balance but does not increase the checking balance the customer is quite unhappy and the data s integrity and possibly the bank manager s office is damaged. Business rule violations Although rules are generally meant to be broken from time to time this is not true with information carefully entrusted to your SQL Server Express database. For example you might be building an application to track credit ratings for your customers. Valid values for the credit score range between 0 and 100. If a rogue person or .
đang nạp các trang xem trước