Welcome: To the fifth learning sequence “ Data Models “ Recap : In the previous learning sequence, we discussed The Database concepts. Present learning: We shall explore the following topic: - The most common types of data models. Data Models The goal of the data model is to make sure that the all data objects required by the database are completely and accurately represented. Data Models Importance •Data modeling is probably the most intensive and time consuming part of the development process •Building a database without a model is like building a house without plans Data Models •Because the data model uses easily understood notations and natural language it can be reviewed and verified by end-users •Detailed enough to be used by the database developers to use as a blueprint for building the physical database Data Models •The information contained in the data model will be used to define the relational tables primary and foreign keys stored procedures and triggers •A poorly designed database will require more time in the long-term . Data Models Model : as description or analogy used to visualized something that be directly observed. Data model: a collection of concepts that can be used to describe the structure of a database provides the necessary means to achieve this abstraction, by structure of a database , we mean the data types , relationships , and constraints that should hold for the data . Most data models also include a set of basic operations for specifying retrievals and updates on the database . Data Models Some types of data model : Hierarchical Model * Network Models * Relational Models * * Object-Oriented Model * Object-Relational Model * NoSQL Model * XML Model Data Models The hierarchical data models organizes data in a tree structure . There is a hierarchy of parent and child data segments, this structure implies that a record can have repeating information, generally in the child data segments, data in a series of records, which have a set of field values attached to it . Data Models Network data model : The popularity of the network data model coincided with the popularity of the hierarchical data model. Some data were more naturally modeled with more than one parent per child, so the network model permitted the modeling of many -to-many relationships in data . Data Models Relational data model : A relational database allows the definition of data structures, storage and retrieval operations and integrity constraints, in such a database the data and relations between them are organized in tables. A table is a collection of records and each record in a table contains the same fields. Data Models Object-Oriented data Model : Object DBMSs add database functionality to object programming languages, they bring much more than persistent storage of programming language objects. Object DBMSs extend the semantics of the C++ , smalltalk and java object programming languages to provide full-featured database programming capability, while retaining native language compatibility . Data Models The American National Standards Institute / Standard Planning And Requirement Committee (ANSI / SPARC) define 3 degrees of abstraction as illustrated in Figure 1. Data Models The architecture is divided in to three general levels: 1- External levels This level is concerned with the way in which the data is viewed by individual users i.e (logical storage). 2- Internal levels This level is concerned with the way in which the data is actually stored i.e (physical storage). 3- Conceptual level It is the level of indirection between the other two levels (External & Internal levels). ANSI/SPARC ANSI/SPARC External Level • Represents the user’s view of the database – Consists a different view of the database for each user. • Describes the part of the database that is relevant to each user – For example, in large organizations, the users in each department will require different user view (interface). Details needed by Finance department differs than needed by HR. • Views may provide different representations of the same data – Date may be formatted (day/month/year) or (year/month/day), according to user preference. • Some views might include derived or calculated data – Date of birth is stored, but in a user view the Age is calculated. ANSI/SPARC Conceptual Level • It describes what data is stored in the database and the relationships among the data. • It is a complete view of the data requirements of the organization that is independent of any storage consideration. • The conceptual level represents: – All entities ,their attributes, and their relationships. – The constraints on the data. – Security and integrity information. • The conceptual level supports each external view, so that any data available to the user must be contained or derived from the conceptual level. • these models, sometimes called domain models , are typically used to identify and document business (domain) concepts with project stakeholders(users).. ANSI/SPARC Internal Level • It covers the physical representation of the database on the computer. • It describes how the data is stored in the database in terms of particular data structures and file organizations. • The internal level is concerned with: – Allocating storage space for data and indexes. – Describing the forms that records will take when stored. – Record placement. Assembling records into files. – Data compression and encryption techniques. • The internal level interfaces with the OS to place data on the storage devices, build the indexes, retrieve the data, etc. • It deals with the mechanics of physically storing data on a device such as a disk. ANSI/SPARC Database Schemas • The overall description of a database is called the database schema. • There are three different types of schema corresponding to the three levels in the -ANSI/SPARC architecture. – External schema (many schemas may exist) – Conceptual schema (only one per database) – Internal schema (only one per database) • The DBMS is responsible for mapping between the three types of schema (i.e. how they actually correspond with each other). • Each external schema is related to the conceptual schema (external/conceptual mapping). • A conceptual/internal mapping relates the conceptual schema to the internal schema. ANSI/SPARC User A1 Language Workspace User A2 User B1 Language Workspace Data Base Administrator (DBA) * Language Workspace Ext. External Schema A Model A Ext./Con. Mapping A Conc. Schema User B2 Language Workspace User B3 Language Workspace . * Ext. External Schema B Model B Conceptual Model Ext./Con. Mapping B DBMS * User interface Inte. Schema Stored database (Internal Model) Fig.1: An Architecture for Database System ANSI/SPARC ANSI/SPARC • The main objective of the three-level architecture is to “separate the users’ view(s) of the database from the way it is physically represented”, which will result: – Allowing independent customized user views. – Hiding the physical storage details from the users. – The DBA can change the database storage structures without affecting the users’ views. – Conceptual structure can be changed without affecting the users’ views. ANSI/SPARC Database languages -- Each user of a database system has a language of his or her disposal. What is important about the used language is that it will include a Data Sub-Language (DSL), which is that subset of the language concerned with database objects and operations. -- Any given DSL is really a combination of: 1- Data Definition Language DDL, which defines the database objects (creating tables, fields, primary and foreign keys) 2- Data Manipulation Language DML, which supports the manipulation or processing of those objects. (Insert, update, delete data) 3- Structured Query Language SQL, which supports displaying and retrieving database objects. - Each user provided with a workspace, which acts as receiving or transmitting area between the user and the database. Data Models Categories of data models : Conceptual data models : these models, sometimes called domain models , are typically used to identify and document business (domain) concepts with project stakeholders. Conceptual data models are often created as the precursor to logical data models (LDMs) or as alternatives to LDMs . Data Models Logical data models (LDMs) : logical data models are used to further explore the domain concepts, and their relationships and relationship cardinalities. This could be done for the scope of a single project or for your entire enterprise. Logical data models depict the logical entity types, typically referred to simply as entity types, the data attributes describing those entities, DDL can be generated at this level . Data Models Physical data models (PDMs) : physical data models are used to design the internal schema of a database, depicting the data tables (derived from the logical data entities), the data columns of those tables (derived from the entity attributes), and the relationships between the tables derived from the entity relationships . Data Models Major event in data model include : - Identifying the data and associated processes. - Defining the data (such as data types , sizes , and defaults). - Specifying data storage requirements. - Defining the data management processes (such as security reviews and backups. - Ensuring data integrity (by using business rules and validation checks). Data Models Summary: In this learning sequence, we discussed the best common types of data models. Data Models end