15.02.2015 Views

C# 4 and .NET 4

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Database <strong>and</strong> entity Classes ❘ 607<br />

aCid Properties<br />

A transaction has specifi c requirements; for example, a transaction must result in a valid state, even if the<br />

server has a power failure. The characteristics of transactions can be defi ned by the term ACID. ACID is a<br />

four - letter acronym for atomicity, consistency, isolation, <strong>and</strong> durability :<br />

➤<br />

➤<br />

➤<br />

➤<br />

Atomicity — Represents one unit of work. With a transaction, either the complete unit of work<br />

succeeds or nothing is changed.<br />

Consistency — The state before the transaction was started <strong>and</strong> after the transaction is completed<br />

must be valid. During the transaction, the state may have interim values.<br />

Isolation — Means that transactions that happen concurrently are isolated from the state, which is<br />

changed during a transaction. Transaction A cannot see the interim state of transaction B until the<br />

transaction is completed.<br />

Durability — After the transaction is completed, it must be stored in a durable way. This means that if<br />

the power goes down or the server crashes, the state must be recovered at reboot.<br />

Not every transaction requires all four ACID properties. For example, a memory - based transaction (for<br />

example, writing an entry into a list) does not need to be durable. Also, a complete isolation from the<br />

outside is not always required, as we discuss later with transaction isolation levels.<br />

daTabase <strong>and</strong> enTiTy Classes<br />

The sample database CourseManagement that is used with the transactions in this chapter is defi ned by the<br />

structure from Figure 23 - 2. The table Courses contains information about courses: course number <strong>and</strong><br />

title. The table CourseDates contains the date of specifi c courses <strong>and</strong> is linked to the Courses table. The<br />

table Students contains information about persons attending a course. The table CourseAttendees is<br />

the link between Students <strong>and</strong> CourseDates . It defi nes which student is attending what course.<br />

You can download the database along with the source code for this chapter from the<br />

Wrox web site.<br />

Courses<br />

CourseId<br />

Number<br />

Title<br />

CourseDates<br />

CourseDateId<br />

CourseId<br />

StartDay<br />

Length<br />

MaxStudentCount<br />

CourseAttendees<br />

CourseAttendeesId<br />

StudentId<br />

CourseDateId<br />

Students<br />

StudentId<br />

FirstName<br />

LastName<br />

Company<br />

figure 23-2<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!