Mba ebooks

24
Free Ebooks Download Mba Ebooks By Edhole Mba ebooks Free ebooks download http://ebooks.edhole.com

description

here you will get awesome study materials

Transcript of Mba ebooks

Page 1: Mba ebooks

Free Ebooks Download Mba Ebooks

By Edhole

Mba ebooks

Free ebooks download

http://ebooks.edhole.com

Page 2: Mba ebooks

Data Integrity

An empty database is a correct database

http://ebooks.edhole.com

Page 3: Mba ebooks

Overview

• Review• Domains• What are integrity constraints?• Gulf between the theory and the implementation• Testing insertions into database?• NULLS

http://ebooks.edhole.com

Page 4: Mba ebooks

Review

• Tuple• Cardinality• Attribute• Degree• Domain

http://ebooks.edhole.com

Page 5: Mba ebooks

Domains• Conceptual pool of values from which one or

more columns draw their values• Named set of scalar values all the same type

– scalar is smallest semantic unit of data, individual data value

• CREATE DOMAIN …? ?• Domain contains ALL permitted values,

static• Which relations in the database contain any

information pertaining to suppliers?• http://ebooks.edhole.com

Page 6: Mba ebooks

Comparisons with Domains• Domains constrain comparisons, = ,<>• domain-check override Codd• Logically equivalent statements must have same

semantic interpretation • Logic cannot be nullified

a = c Tb = c Ta = b F

• Arithmetic operators• http://ebooks.edhole.com

Page 7: Mba ebooks

Data Types

• Hide complexity within domain

• DATE domain

– three integers (d,m,y)

– interpreted by operators

• Address domain

– USA - street, city, state, zip

– http://ebooks.edhole.com

Page 8: Mba ebooks

ADT in Oracle

• Simulate a domain• CREATE TYPE ADDR_TY AS OBJECT

– (STREET VARCHAR2(50),– CITY VARCHAR2(25),– STATE CHAR(2),– ZIP VARCHAR(9));

• CREATE TABLE NEW_CUSTOMER– ( CUSTID VARCHAR2(9) PRIMARY KEY,– CUST_NAME VARCHAR2(25),– ADDRESS ADDR_TY);– http://ebooks.edhole.com

Page 9: Mba ebooks

Relations• Abstract object• A relation, r, on a collection of domains, D1, D2 …

Dn consists of two parts a heading and a body– heading - fixed set of attributes, <attribute-name:domain-

name> pairs

– body - set of tuples, <attribute-name:attribute-vale> pairs

• Named relation is really a variable• Relations dynamic• Table is concrete picture• http://ebooks.edhole.com

Page 10: Mba ebooks

Candidate Keys

• Subset of all attributes that are– Unique– Irreducibile

• Does not relate to current data set but to set of ALL POSSIBLE values– simple– composite

• Provide tuple-level addrressing mechanism• Primary key is selected from candidate key. Others

called Alternate keys

• http://ebooks.edhole.com

Page 11: Mba ebooks

Is our information Correct ?

Consistent ?Logical ?

http://ebooks.edhole.com

Page 12: Mba ebooks

Start with a consistent database

Update the database

Result a consistent database

http://ebooks.edhole.com

Page 13: Mba ebooks

Is the data consistent?

Is the data consistent between tables? Are the same values equivalent? Do foreign keys reference existent primary

keys?Has logical consistency been

maintained?Have the business rules been enforced?All constraints valid?http://ebooks.edhole.com

Page 14: Mba ebooks

How do we maintain correct, consistent data ?

Data Integrity Rules– Candidate keys– Domains

Referential Integrity Rules– Foreign keys

Business Rules– Constraints– Stored Procedures, Triggers

http://ebooks.edhole.com

Page 15: Mba ebooks

Where do we maintain correct, consistent data ?

• Database creation– base tables– views

• Implementation– back end– front end applications– middleware

Integrity rules are database specifichttp://ebooks.edhole.com

Page 16: Mba ebooks

Foreign Keys

• If the foreign key contains either matching values or nulls, the table(s) that make use of such a foreign key are said to exhibit referential integrity.

• An attribute in one table refers to a primary key in another table– can it be a candidate key?– can it be the same table?

• A FK is composite if the primary key is composite.Referential Integrity assures that no invalid foreign keys permitted

• Relationships formed through foreign keys but not exclusively

http://ebooks.edhole.com

Page 17: Mba ebooks

Maintaining Integrity with Foreign Keys

Correct DBCorrect DBTransform thru update

•Delete Parent•restrict•cascades

•Update Parent•restrict•cascade

•How many levels of cascade?•Define procedures

Note: Correct database satisfies logical AND of all known ruleshttp://ebooks.edhole.com

Page 18: Mba ebooks

Entity Integrity• No component of the primary key of a base

relation is allowed to accept NULLS.• In a relational database, we never record

information about something we cannot identify.

• No attribute included in composite primary key can be NULL.

• Can alternate keys have NULLS?

• http://ebooks.edhole.com

Page 19: Mba ebooks

Null Foreign Keys

• Can a foreign key be null?– definition - matches primary key or is null

• Can a composite foreign key have some attributes null?

• ON DELETE SET NULL– allows child record to remain but deleted key attribute

becomes null

http://ebooks.edhole.com

Page 20: Mba ebooks

Rules or Constraints• Theory

– CREATE INTERGIRTY RULE PR4• FORALL PX(PX.WEIGHT>0)• ON ATTMPTED VIOLATION REJECT;

• Oracle– CREATE TABLE PX ...

• WEIGHT NUMBER• CONSTRAINT PR4• CHECK (WEIGHT >0);

• Components name, truth-statement, violation response• http://ebooks.edhole.com

Page 21: Mba ebooks

Relation Rules or Constraints

• Theory– CREATE INTERGIRTY RULE SR8

• FORALL S(IF S.CITY = ‘LONDON’ THEN S.STATUS = 20)• ON ATTMPTED VIOLATION REJECT;

• Oracle

http://ebooks.edhole.com

Must be closed WFF

Page 22: Mba ebooks

Database Rules

• CREATE INTEGRITY RULE C95– FORALL SX (FORALL SPX– (IF SX.STATUS < 20 AND – SX.S# = SPX.S#– THEN SPX>QTY <=500));

• Oracle

Note required join condition

http://ebooks.edhole.com

Page 23: Mba ebooks

Database Rules

• How do we execute the following:– For every orderline there must exist an order.– Every customer must place an order.– No salesrep can have more than 200 customers.– Every orderline must contain a valid part.

• When do we execute

http://ebooks.edhole.com

Page 24: Mba ebooks

Transition Rules

• Applied as go from one state to another

• Employee marries

• CREATE INTEGRITY RULE S12– IF S’.S# = S.S# THEN– S’.STATUS < S.STATUS;

http://ebooks.edhole.com