DB-Notes-Lect2

Embed Size (px)

Citation preview

  • 8/7/2019 DB-Notes-Lect2

    1/4

    Description of the properties

    ACID stands for

    y Atomicity

    y Consistency

    y Isolationy Durablity

    Atomicity

    Modification on the data in the database either fails or succeed. The beginning of such a modification

    starts with a transaction and ends when a transaction finishes (either by a commit or arollback). A

    software crash entails an implicit rollback.

    Consistency

    Only valid data (valid according to integrity constraints) may be commited.

    Integrity Constraints:

    Not Null, Primary Key, Unique Key, , Foreign Key Relation

    Isolation

    One transaction does not interfere with another. The 'executor' of a transaction has the feeling that he

    has the entire database for himeself.

    Durablity

    A committed transaction will not be lost

    Atomicity

    Atomicity requires that database modifications must follow an "all or nothing" rule. Each transaction is

    said to be atomic. If one part of the transaction fails, the entire transaction fails and the database state

    is left unchanged. It is critical that the database management system maintain the atomic nature of

    transactions in spite of any application, DBMS (Database Management System), operating system or

    hardware failure.

    Consistency

    It ensures the truthfulness of the database.

    The consistency property ensures that any transaction the database performs will take it from one

    consistent state to another.

    The consistency property does not say how the DBMS should handle an inconsistency other than ensure

    the database is clean at the end of the transaction. If, for some reason, a transaction is executed that

  • 8/7/2019 DB-Notes-Lect2

    2/4

    violates the databases consistency rules, the entire transaction could be rolled back to the pre-

    transactional state - or it would be equally valid for the DBMS to take some patch-up action to get the

    database in a consistent state. Thus, if the database schema says that a particular field is for holding

    integer numbers, the DBMS could decide to reject attempts to put fractional values there, or it could

    round the supplied values to the nearest whole number: both options maintain consistency.

    Isolation

    Isolation refers to the requirement that other operations cannot access data that has been modified

    during a transaction that has not yet completed. The question of isolation occurs in case of concurrent

    transactions (multiple transactions occurring at the same time). Each transaction must remain unaware

    of other concurrently executing transactions, except that one transaction may be forced to wait for the

    completion of another transaction that has modified data that the waiting transaction requires. If the

    isolation system does not exist, then the data could be put into an inconsistent state. This could happen,

    if one transaction is in the process of modifying data but has not yet completed, and then a second

    transaction reads and modifies that uncommitted data from the first transaction.

    Durability

    Durability is the ability of the DBMS to recover the committed transaction updates against any kind of

    system failure (hardware or software). Durability is the DBMS's guarantee that once the user has been

    notified of a transaction's success the transaction will not be lost, the transaction's data changes will

    survive system failure, and that all integrity constraints have been satisfied, so the DBMS won't need to

    reverse the transaction. Many DBMSs implement durability by writing transactions into a transaction

    log that can be reprocessed to recreate the system state right before any later failure. A transaction is

    deemed committed only after it is entered in the log.

  • 8/7/2019 DB-Notes-Lect2

    3/4

    A relational database is a set of tables containing data fitted into predefined categories. Each table

    (which is sometimes called a relation) contains one or more data categories in columns. Each row

    contains a unique instance of data for the categories defined by the columns. For example, a typical

    business order entry database would include a table that described a customer with columns for name,address, phone number, and so forth. Another table would describe an order: product, customer, date,

    sales price, and so forth. A user of the database could obtain a viewof the database that fitted the user's

    needs. For example, a branch office manager might like a view or report on all customers that had

    bought products after a certain date. A financial services manager in the same company could, from the

    same tables, obtain a report on accounts that needed to be paid.

    The relational database model was a huge step forward, as it allowed files to be related by

    means of a common field. In order to relate any two files, they simply need to have a common

    field, which makes the model extremely flexible

    A DBMS is essentially a suite of programs that act as the interface between the human operator and the

    data held in the database. Using the DBMS, it is possible to retrieve useful information, update or delete

    obsolete information and add new information to the database. As well as data entry and retrieval, the

    DBMS plays an important role in maintaining the overall integrity of the data in the database. The

    simplest example of is ensuring that the values entered into the database conform to the data types

    that are specified. For example, in the telephone book database, the DBMS might have to ensure that

    each phone number entered conforms to a set format of XXX-XXXXXXX where X represents an integer.

    Basic Terms

    An understanding of relational databases requires an understanding of some of the basic terms.

    y Data are the values stored in the database. On its own, data means very little. "43156" is an

    example.

    y Information is data that is processed to have a meaning. For example, "43156" is the population

    of the town of Littlewood.

    y A database is a collection of tables.

    y Each table contains records, which are the horizontal rows in the table. These are also called

    tuples.

    y Each record contains fields, which are the vertical columns of the table. These are also called

    attributes. An example would be a product record.

    y

    Fields can be of many different types. There are many standard types, and each DBMS (databasemanagement system, such as Oracle or MySQL) can also have their own specific types, but

    generally they fall into at least three kinds - character, numeric and date. For example, a product

    description would be a character field, a product release date would be a date field, and a

    product quantity in stock would be a numeric field.

    y The domain refers to the possible values each field can contain (it's sometimes called a field

    specification). For example, a field entitled "marital_status" may be limited to the values

    "Married" and "Unmarried".

  • 8/7/2019 DB-Notes-Lect2

    4/4

    y A field is said to contain a null value when it contains nothing at all. Fields can create

    complexities in calculations and have consequences for data accuracy. For this reason, many

    fields are specifically set not to contain NULL values.

    y A key is a logical way to access a record in a table. For example, in the product table, the

    product_id field could allow us to uniquely identify a record. A key that uniquely identifies a

    record is called a primary key.

    y An index is a physical mechanism that improves the performance of a database. Indexes are

    often confused with keys. However, strictly speaking they are part of the physical structure,

    while keys are part of the logical structure.

    y A view is a virtual table made up of a subset of the actual tables.

    y A one-to-one (1:1) relationship occurs where, for each instance of table A, only one instance of

    table B exists, and vice-versa. For example, each vehicle registration is associated with only one

    engine number, and vice-versa

    y A one-to-many (1:m) relationship is where, for each instance of table A, many instances of the

    table B exist, but for each instance of table B, only once instance of table A exists. For example,

    for each artist, there are many paintings. Since it is a one-to-many relationship, and not many-

    to-many, in this case each painting can only have been painted by one artist.

    y A many to many (m:n) relationship occurs where, for each instance of table A, there are manyinstances of table B, and for each instance of table B, there are many instances of the table A.

    For example, a poetry anthology can have many authors, and each author can appear in many

    poetry anthologies.

    y A mandatory relationship exists where, for each instance of table A, one or more instances of

    table B must exist. For example, for a poetry anthology to exist, there must exist at least one

    poem in the anthology. The reverse is not necessarily true though, as for a poem to exist, there

    is no need for it to appear in a poetry anthology.

    y An optional relationship is where, for each instance of table A, there may exist instances of table

    B. For example, a poet does not necessarily have to appear in a poetry anthology. The reverse

    isn't necessarily true though, for example for the anthology to be listed, it must have some

    poets.y Data integrity describes the accuracy, validity and consistency of data. An example of poor

    integrity would be where a poet's name is stored differently in two different places.