Data Models
A description of a database is known as Schema. What is Schema ??? A description of a database is known as Schema.
What is Instance ??? Record at a particular moment of time in a database is known as Instance.
What is Data Model??? A data model is an abstract model that describes how data is represented and accessed.
Meanings of Data Model Data Model Theory Data Model Instance
A formal description of how data may be structured and accessed Data Model Theory A formal description of how data may be structured and accessed
Components of Data Model Theory Structural Part (data structure used to create databases representing entities or modeled by database using create command ) Integrity Part (rules governing the constraints placed on these data structures like applying constraints such as primary key , foreign key) Manipulation Part (a collection of operators used to manipulate the database using queries and update command)
Example of Relational Model Structural Part (based on modified concept of mathematical relation) Integrity Part (by using first order logic) Manipulation Part (using relational algebra , tuple calculus and domain calculus)
Data Model Instance Data Modeling is the process of creating a data model instance by applying a data model theory.
It involves structuring and organizing the data. Data Modeling It is a process of creating a data model by applying data model theory to create a data model instance. It involves structuring and organizing the data.
High Level (Conceptual Schema) Low Level (Physical Schema) Types of Data Model High Level (Conceptual Schema) Low Level (Physical Schema) Representational Data Model Hierarchical Relational Networked ( Logical Schema )
Conceptual Schema It is used to describe the semantics of a domain, being the scope of the model. It consists of Entity Classes and relationships among these entities.
Logical Schema It describes the semantics as represented by the particular data manipulation technology. It consists of description of tables , columns object oriented classes etc.
Physical Schema It describes the physical means by which data is stored. It is concerned with partitions , table spaces etc.
Zachman Framework Contextual List (List of Important Things) Conceptual Model (Entities & Relationships) Logical Model (attributes & identifiers) Physical Model (keys , storage requirements) DDL (Configuration Listing) Data Instances (Operations Storage) Zachman Framework
What is Logical Data Model??? A data model is an abstract model that describes how data is represented and accessed.
Graphical Representations of the business requirements Contains the things of importance in an organization and how they relate to one another Contains business textual definitions and examples Validated and approved by a business representative Basis of Physical Database design
Logical Data Model Vs Physical Data Model Includes Entities ,attributes and relationships Includes tables,columns,keys,data types,validation rules,database triggers stored procedures and access controls Uses business names for attributes Uses column names limited by DBMS Is independent of technology Includes Primary key and indices for fast data acces
Is normalized to 4th Normal Form. Can be de normalized to meet performance requirements Does not include any redundant or derived data May include redundant columns Business subject matter experts validate and approve the model Physical modeler lead the modeling activity
Why build Logical Data Model??? Helps common understanding of business requirements Provides foundation for designing a database Facilitates data re use and sharing Decreases development and maintenance time and cost Confirms a logical process model and helps impact analysis
Logical Modeling Benefits Clarifies functional specifications and avoid assumptions Confirms Business requirements Facilitates business process improvement Decreases system development time and cost Data re-using and sharing Gathers Metadata
3 Schema Architecture of DBMS View 1 View 2 High Level DM Representational DM High Level DM Conceptual Layer Internal Layer Low Level DM
What is Data Independence??? It is a capability to change a specific layer without affecting the other two layers.
Types of Data Independence Logical Data Independence Physical Data Independence
Logical Data Independence The capability to change a conceptual layer without affecting the other two layers
Physical Data Independence Capability to change physical layer without affecting the other two layers
It is database model proposed by Dr. E F Codd. Relational Data Model It is database model proposed by Dr. E F Codd. Core idea is to organize data into tables rows and columns). Follows simple concept of relational algebra
Networked Data Model It is a database model conceived as a flexible way of representing objects and their relationships. It was invented by Charles Bachman. NM allows each record to have multiple parent and child records forming a lattice structure.
Hierarchical Data Model Data is organized in a tree like structure. It allows repeating information using parent/child relationships. Each parent can have multiple child but each child has single parent. It uses 1:N mapping also known as one to many relationships.
Object Oriented Data Model Data and associated operations are represented by objects. An object is an identifiable entity with some characteristics and behavior.
What Is Relation ??? A relation is defined as a set of n tuple (rows) which stores the data logically in a 2-D format in forms of rows and columns.
Relation : Employee Attributes : Emp_id , ename , designation ,dept Emp_id ename designation dept E001 Raghav AM Civil E002 Smriti MANAGER HR E003 Ashwin DM Finance
Relational Algebra Projection Selection Union Intersection Difference Cartesian Product
Two relations A and B are said to be union compatible if and only if Union Compatibilty Union Compatible relations are those relations which have same domain and degree. Two relations A and B are said to be union compatible if and only if Deg(A)=Deg(B) Dom(a1)=dom(b1) Dom(a2)=dom(b2) .. Dom(an)=dom(bn)
Cardinality No of rows in a relation.
One to one (1 : 1) One to many (1 : M) Many to many (M:N) Cardinality Ratio One to one (1 : 1) One to many (1 : M) Many to many (M:N)
Referential Integrity Key Constraints. Types of Constraints Entity Integrity Referential Integrity Key Constraints.
Types Of Key Constraints Super Key Candidate key Primary Key Alternate Key Foreign Key
A super key is written as a finite set of attribute names. A super key K holds in a relation (H,B) if: K is proper subset of H and There exists two distinct tuples t1 and t2 which must hold the condition T1[k] = t2[k]
Data Modeling Techniques ER diagrams EER diagrams OMT
E R Diagram Works_in Department Employee
Single Valued / Multivalued Stored and Derived Types of Attributes Atomic and Composite Single Valued / Multivalued Stored and Derived
Types of Entities Strong Entity Weak Entity
Types of Participation Constraints Total Participation Partial Participation
Example Database Customer(Customer_id,Tax_id,Name,Address,City,State, Zip,Phone) Order(Orderno,Cust_id,invoice_no,date placed,date promised,terms,status) Order Line(Orderno,Orderlineno,product code,qty) Invoice(Invoice_no,Cust_id,Order_no,date,Status) Invoice Line(Invoiceno,lineno,product_code,qty,shipped) Product(Product_code,prod_desc)