Anda di halaman 1dari 16

UNIT II PRINCIPLES OF CONCEPTUAL DESIGN Model: A model is a representation of reality that retains only selected details.

A database incorporates a model of reality. The DBMS manages the database so that each user can record, and manipulate the data that constitute his or her model of reality. Thus, models are powerful tools for eliminating irrelevant details and understanding the reality of individual users. Map: To create a model, mapping has to be done which means that u must associate or map, elements in reality to elements in the model. Note: If mapping is done properly, then the model can be used to solve the problem else produces wrong solution. Conceptual Data Models - Object Oriented Model: A model representing real world entities as objects having their own object identities and attributes and participating in relationships rather than records in traditional file oriented systems. - Conceptual Model: A model that captures the meanings of real world entities and relationships. Aggregation Aggregate: A relationship viewed as an object set. I.e.

Relationships that can be viewed as objects and can have attributes and participate in other relationships are called aggregates. Ex: we noted that each man and woman are related by ISMARRIED-TO relationship constitute a married couple, which itself is an object having attributes like anniversary date, total earnings, address, and it can even participate in other relationships like OWN-AUTOMOBILE and PARENTS-OF. Thus, IS-MARRIED-TO relationship can be viewed as an object set whose elements are married couples. Types - Binary relationship: A relationship between two object sets - N-ary relationship: A relationship between n object sets Where n stands for the number of object sets being related. Ex: 3-ary as three-way or ternary relationship 4-ary as four-say relationships Ex: premier Construction Co. pg no 111 & 112 (Fig 4.33) Modeling Conceptual Objects Versus Physical Objects Aggregation & higher-level relationships are very useful tools for solving variety of data modeling problems. Data modeling problems can be solved by defining appropriate object sets, later aggregation and other concepts

can be used to build additional constructs into the data model as required. Conceptual Object Set: An object set whose instances are conceptual objects. Ex: MATERIAL TYPE & CREW TYPE Physical Object Set: An object set whose instances are physical objects. Ex Creating Library Data Model Figure 4.13 Pg no 123 THE RELATIONAL DATA MODEL The Relational Data Model: Fundamental Concepts Relational Model: A data model that organizes and represents the data in the form of tables or relations. It is developed by E.F.Codd in 1970 which is based on mathematical sets and relations. Relation: It is a term that comes from mathematics and represent two-dimensional table consisting of rows and columns of data. Relational Data Model Terminology Relation : table name Tuple : a row in a relation Attribute or attribute name: name of the column

Attribute domain : the set from which an attribute takes its values Degree of relation : the number of attributes in a relation NULL VALUES The value given to an attribute in a tuple, if the attribute is inapplicable or its value is unknown It is not same as ZERO or Blank. Ex: Some employees in the WOKER relation do not have supervisors. KEYS (Important) Key A minimal set of attributes that uniquely identifies each row in a relation Super Key A set of attributes that uniquely identifies each row in a relation Ex: value of the attribute set {WORKER-ID, NAME} in WORKER relation Uniquely identifies any tuple in the relation. Therefore, this set is a super key for WORKER. However, this set of attributes is not minimal and is therefore is not Key WORKER-ID by itself is a key, since any row in the relation is uniquely identified by WORKER-ID. Composite Key A key consisting of more than one attribute Ex:

ASSIGNEMNT(WORKER-ID,BLDNG-ID,STARTDATE,NUM-DAYS) Candidate Key Any set of attributes that can be chosen as a key of a relation Ex: NAME is a candidate key in WORKER relation. This would be so if we could assume that NAME will always be unique. If we cannot make that assumption, then NAME is not a candidate key. Primary Key The candidate key designated for principal use in uniquely identifying rows in a relation. Eg: WORKER(WORKERID,NAME,HOURLYRATE,SKILLTYPE,SUPVID) Foreign Key - A set of attributes in one relation that constitutes a key in some other (possibly the same) relation used to indicate logical links between relations. Ex: SKILL-TYPE in the WORKER Relation and BLDNG-ID in the ASSIGNMENT relation since, SKILL-TYPE Is the key of SKILL relation and BLDNG-ID is the key of BUILDING relation. Foreign keys are the essential links between relations. They are used to tie data in one relation to data in another relation. Thus, SKILL-TYPE links the WORKER relation to the SKILL relation and WORKER-

ID and BLDNG-ID in the ASSIGNMENT relation show the link between WORKER and BUILDING. Recursive Foreign Key: A foreign key that references its own relation. Ex: EMPLOYEE(empno,ename,job,sal,mgr) Mgr references empno Integrity Constraints (Important) Constraint is a rule that restricts the values in a database. Types of Integrity Constraints - Domain integrity constraints - Entity integrity constraints - Referential integrity constraints Domain Integrity Constraints These constraints set a range, and any violations that take place will prevent the user from performing the manipulation that caused the breach. Ex: Not Null constraint Check constraint Not Null Constraint By default, tables can contain null values. The enforcement of Not Null Constraints in a table ensures that the table contains values.

Check Constraint It can be defined to allow only a particular range of values. Entity Integrity Constraints - These constraints set unique and primary key values and any violation that takes place will prevent the user from performing the manipulation. Ex: Unique Constraint Primary Key Constraint Unique Constraint It designates a column or group of columns as unique key. This constraint allow only unique values to be stored in the column i.e. rejects the duplication of records when unique key constraint is used. Primary Key It designates a column or group of columns as primary key. This constraint does not allow duplicate and null values. Referential Integrity Constraints Ex. Foreign Key It enforces relationship between tables. It designates a column or combination of columns as foreign key. The foreign key establishes a relationship with specified primary or unique key in another table called referenced key. In this relationship, table containing foreign key is called child table and the table

containing the referenced key is called the parent table. NORMALIZATION (important) It is the process of decomposing (splitting) relations into small and well structured relations by removing anomalies to avoid data redundancy. Data redundancy: unnecessary repeatation of data in a database Anamoly bug or error in the database design Types of anomalies - insertion anomaly : inability to add data to the database due to absence of other data - deletion anomaly : unintended loss of data due to deletion of other data - update anomaly : data inconsistency resulting from data redundancy and partial update Steps in Normalization Process (Diagram)

Normal Forms: Rules for structuring relations into multiple relations

To understand the concept of Normalization, first we should understand the concept of dependencies. Functional dependency (FD): The value of an attribute in a tuple determines the value of another attribute in the tuple Determinant: The attribute(s) on the left side of functional dependency, determine(s) the value of other attributes in the tuple. X->Y Ex: Employee (empno, ename, job, sal, deptno) FD: empno -> ename, job, sal, deptno First Normal Form (1NF) : A relation is said to be in 1NF, if the values in the relation are atomic for every attribute in the relation which means that no attribute value can be set of values. Example: Second Normal Form (2NF) : A relation is said to be in 2NF, in it is in 1NF and if no monkey attribute is functionally dependent on just part of the key i.e. no partial dependency exit (PD is the dependency which is established when non key attributes are based on only part of the primary key) Example:

Third Normal Form (3NF): A relation is said to be in 3NF, if it is in 2NF and contains no transitive dependency ((TD is the dependency which is established when monkey attribute is functionally dependent on one or more than other monkey attributes) Example: Boycee Codd Normal Form (BCNF) Every determinant is a key Example: Fourth Normal Form (4NF) A relation that is in 3NF and has no multivalued dependencies. Other Normal Forms Fifth Normal Form (5NF) A normal form that eliminates join dependencies Domain Key Normal Form A relation is said to be in domain key normal form if and only if every constraint on the relation is a consequence of the definitions of domains and keys.

Relational Database implementation The languages and systems used for database system implementation in the relational model include relational algebra and calculus. Relational Algebra and Calculus (Important) Relational algebra : It is a procedural language for manipulating relations i.e. relational algebra uses step-bystep approach to create a relation containing the data that answer the query. Relational Calculus: It is non procedural language for defining query solutions. Procedural language: it is a language that provides step by step method for solving problems Non procedural language: it is a language that provides means for stating what is desired rather than how to get it. Relational algebra Relational algebra operations manipulate relations i.e these operations uses one or two existing relations tp create a new relation.

Relational Algebra Operations union intersection difference product select project join divide assignment Union: The union operation (U) allows to combine the data from two relations. Ex: SALESPERSON: = SP_SUBORD U SP_MGR Intersection The intersection operation () allows to identify the row that is common to two relations. Ex: SALESPERSON: = SP_SUBORD SP_MGR Difference : The difference operation ( -) allows to identify rows that are in one relation and not in another Ex: SALESPERSON := SP_SUBORD - SP_MGR Product: The product operation (*) creates the Cartesian products of two relations Ex: SALESPERSON: = SP_SUBORD * SP_MGR

Select: The select operation is used to create a relation from another relation by selecting only those rows from the original relation that satisfy specified condition. Ex: Give all information for salespeople in Warangal office SP_WGL:= SELECT (SALESPERSON: OFFICE=wgl) Note: comparison operators like = , <, >, >=, <=, not=can be used Project: The project operation creates a relation by deleting columns from existing relation (selecting only wanted columns) Ex: SP_WGL (SALESPERSON_NAME) Join: It is used to connect data across relations. Types of joins - the natural join - the theta join - the outer join

Natural Join: Join operation that connects relations when common columns have equal values. Ex: join(sale, customer) Ex: equi join operation of SQL Theta Join: Join operation that connects relations when values from specified columns have a specified relationship Note: comparison operators like =, <, >, >=, <=, not=can be used Outer Join: Expansion of the natural join that includes all rows from both relations Ex: Outer join (salesperson, sale) Ex: outer join (+) operation of SQL Divide (/) : Relational algebra operation that creates a new relation by selecting the rows in one relation that match every row in another relation PI:=PRODUCT[PROD_ID] PI_SI:=SALE [PROD_ID, SALPAPERS_ID]

A:=PI_SI/PI Assignment: Relational operation that gives a name to a relation Ex: A: =SELECT (SALESPERSON: COMM_%>11) Relational Calculus It uses different approach than relational algebra but the two languages are logically equivalent which means that any query that can be solved in one language can be solved in other language. New Constructs in Relational Calculus The Existential Qualifier: Relational calculus expression affirming the existence of at least one row to which a condition applies. The Universal qualifier: Relational calculus expression stating that some condition applies to every row of some type. It is used to provide the same capability as relational algebras divide operation. ******

Anda mungkin juga menyukai