O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

BIS06 Physical Database Models

Course Material for MBA Course on Business Information Systems

  • Seja o primeiro a comentar

BIS06 Physical Database Models

  1. 1. Business Information Systems Physical Data Modeling
  2. 2. Mapping Logical to Physical Model <ul><li>the entity names have been changed to table names, changed attribute names to column names, assigned nulls and not nulls, and datatype to each column. </li></ul>Comment Definition Foreign Key Relationship Check Rule, Default Value Rule Non Unique Index Inversion Key Unique Key or Unique Constraint Alternate Key Primary Key Constraint Primary Key Column Attribute Table Entity Represents the physical implementation of the model in a database. Represents business information and defines business rules Physical Data Model Logical Data Model
  3. 3. The Physical Data Model <ul><li>Includes all required tables, columns, relationships, database properties for the physical implementation of databases. </li></ul><ul><li>Database performance, indexing strategy, physical storage and denormalization are important parameters of a physical model. </li></ul><ul><li>Logical data model is approved by functional team and there-after development of physical data model work gets started. </li></ul><ul><li>The transformations from logical model to physical model include imposing database rules, implementation of referential integrity, super types and sub types etc. </li></ul>
  4. 4. DBMS <ul><li>A database is a collection of organized and structured data, stored in the computer as files. Various data types like numeric, textual, image, multimedia etc., can be managed and maintained more efficiently in a database. </li></ul><ul><li>Often used databases (RDBMS) in most of the practical applications are Oracle, Sql Server, Informix, Terradata, DB2 etc., </li></ul><ul><li>Some Oracle Objects </li></ul><ul><ul><li>Instance </li></ul></ul><ul><ul><li>Schema </li></ul></ul><ul><ul><li>Table </li></ul></ul><ul><ul><li>Column </li></ul></ul><ul><ul><li>Datatype </li></ul></ul><ul><ul><li>Primary Key Constraint </li></ul></ul><ul><ul><li>Unique Constraint </li></ul></ul><ul><ul><li>Check Constraint </li></ul></ul><ul><ul><li>Null / Not Null </li></ul></ul><ul><ul><li>Index </li></ul></ul><ul><ul><li>Sequence </li></ul></ul><ul><ul><li>View </li></ul></ul><ul><ul><li>Materialized View </li></ul></ul><ul><ul><li>Synonym </li></ul></ul><ul><ul><li>Procedure </li></ul></ul><ul><ul><li>Function </li></ul></ul><ul><ul><li>Package </li></ul></ul><ul><ul><li>Trigger </li></ul></ul>
  5. 5. Overview of objects <ul><li>A database instance can have many schemas; </li></ul><ul><li>A schema </li></ul><ul><ul><li>contains multiple database objects like tables, views </li></ul></ul><ul><li>Tables </li></ul><ul><ul><li>A set of related data, arranged in the form of rows and columns. </li></ul></ul><ul><li>Columns </li></ul><ul><ul><li>Also known as Field that provides the structure for organizing the rows and contains the related information. </li></ul></ul><ul><ul><li>Datatype : This is set of property associated with a column, which helps to store and identify the type of data and its length. </li></ul></ul>
  6. 6. Constructs for “constraints” <ul><li>Null / Not Null </li></ul><ul><ul><li>A value that indicates that the column contains should or should not have a valid data </li></ul></ul><ul><li>Primary Key Constraint </li></ul><ul><ul><li>This is a constraint imposed on the column so that all values in the column should be different from each other. This constraint can be imposed on one column or group of columns. he primary key will be always used as a parent key when adding a referential constraint by connecting it to a child table. </li></ul></ul><ul><ul><li>Unique Constraint: Unique + Null Values </li></ul></ul><ul><ul><li>Primary Key Constraint: Unique + Not Null Values </li></ul></ul><ul><li>Foreign Key Constraint </li></ul><ul><ul><li>This is a constraint imposed on the child table. Whatever values are present in the child table, their corresponding values should be present in the parent table. This constraint can be imposed on one column or group of columns and NULL values are allowed in the child table. </li></ul></ul><ul><li>Check Constraint </li></ul><ul><ul><li>This is a constraint that is imposed to validate the data within some value or range of values. This constraint can be imposed on one column or group of columns. </li></ul></ul>
  7. 7. Constructs for “better” access <ul><li>Index </li></ul><ul><ul><li>Index is a database object that enables faster retrieval of data. Unique Index, Bitmap Index etc., are the different types of Index. </li></ul></ul><ul><li>Views </li></ul><ul><ul><li>This is a PSEUDO table that is not stored in the database and it is just a query. </li></ul></ul><ul><ul><li>Materialized Views are similar to a view but these are permanently stored in the database and often refreshed. This is used in optimization for the faster data retrieval and is useful in aggregation and summarization of data. </li></ul></ul>
  8. 8. Constructs for ‘automatic’ processing <ul><li>Procedure </li></ul><ul><ul><li>This is a program that contains set of code, which will carry out a specific action when called by other programs. </li></ul></ul><ul><li>Functions </li></ul><ul><ul><li>This is a program that contains set of code, which will do a specific action when called by other programs. It will return a single VALUE </li></ul></ul><ul><li>Trigger </li></ul><ul><ul><li>This is a program that contains set of code for doing some useful action when a record is inserted or deleted or updated in a table. </li></ul></ul>
  9. 9. Raw Data on Employees <ul><li>For the sample data provided in the table, as a Data Modeler you have to design logical data model, physical data model and generate DDL scripts. </li></ul><ul><li>In order to do the above tasks, you need to create the following: </li></ul><ul><ul><li>Create 2 tables DEPARTMENT, EMPLOYEE. </li></ul></ul><ul><ul><li>Assign correct datatypes to the columns. </li></ul></ul><ul><ul><li>Create constraints like primary key, unique key, null, not null, check to the columns. </li></ul></ul><ul><ul><li>Assign correct PHYSICAL names for tables and columns. </li></ul></ul><ul><ul><li>Select DEPARTMENT as parent table and EMPLOYEE as the child table and connect them. </li></ul></ul>
  10. 10. Employee Table
  11. 11. DEPARTMENT Table <ul><li>Since ‘dept’ will be repeated for several records in EMPLOYEE table, you have to design this lookup for saving disk space. Sometimes the detail table may not show all information </li></ul><ul><ul><li>For example nuances of department name </li></ul></ul><ul><ul><li>Department could have additional information, viz location, manager </li></ul></ul><ul><li>You have to create a column Dept Code, which is not present in sample data and this column should be assigned Primary Key to validate the detailed data in EMPLOYEE table. </li></ul>
  12. 12. DDL : Creating Tables <ul><li>Create the Department Lookup Table </li></ul><ul><ul><li>CREATE TABLE DEPARTMENT ( DEPT_ID NUMBER(2) NOT NULL, DEPT_NAME VARCHAR(50) NOT NULL, LOCATION VARCHAR(10), </li></ul></ul><ul><ul><li>MANAGER NUMBER(6), </li></ul></ul><ul><ul><li>CONSTRAINT DEPARTMENT_PK PRIMARY KEY (DEPT_ID ), ); </li></ul></ul>An Oracle database consists of DDL commands, which are useful to create, modify and drop the database objects. In this section, we will try to explain about important database CREATE commands that are used by a data modeller by relating it with our example data.
  13. 13. The Main Table <ul><li>Create the final employee detail table </li></ul><ul><ul><li>CREATE TABLE EMPLOYEE ( EMP_ID NUMBER NOT NULL, FIRSTNAME VARCHAR(30) NOT NULL, LASTNAME VARCHAR(30) NOT NULL, JOBDESC VARCHAR(10), </li></ul></ul><ul><ul><li>JOINDATE DATE, </li></ul></ul><ul><ul><li>EMP_SAL NUMBER(7,2) NOT NULL, </li></ul></ul><ul><ul><li>COMM NUMBER (3,2), </li></ul></ul><ul><ul><li>DEPT_CD NUMBER(2) CONSTRAINT EMPLOYEE_PK PRIMARY KEY (EMP_ID ), CONSTRAINT EMPLOYEE_FK01 FOREIGN KEY (DEPT_CD ) REFERENCES DEPARTMENT ); </li></ul></ul>
  14. 14. More Automation <ul><li>Defining a sequence </li></ul><ul><ul><li>CREATE SEQUENCE SEQ_EMPLOYEE_DTL INCREMENT BY 1 START WITH 1 NOMAXVALUE NOMINVALUE NOCACHE NOCYCLE NOORDER ; </li></ul></ul><ul><li>Defining a trigger </li></ul><ul><ul><li>CREATE OR REPLACE TRIGGER TRG_SEQ_EMPLOYEE_DTL BEFORE INSERT ON EMPLOYEE FOR EACH ROW BEGIN SELECT SEQ_EMPLOYEE.NEXTVAL INTO :NEW.EMP_ID FROM DUAL; END; </li></ul></ul><ul><li>Installing a trigger </li></ul><ul><ul><li>Whenever a record is inserted into &quot;EMPLOYEE_DTL&quot; table, this trigger selects the next unique number from the sequence &quot;SEQ_EMPLOYEE_DTL&quot; and inserts into the column &quot;EMP_ID&quot;. </li></ul></ul><ul><ul><li>In our INSERT STATEMENTS example, we have not provided values for the column &quot;EMP_ID&quot; and inserting values into &quot;EMP_DTL_ID is taken care by sequence and trigger. </li></ul></ul>
  15. 15. Altering Tables <ul><li>Add Columns </li></ul><ul><ul><li>ALTER TABLE EMPLOYEE ADD PASSPORT_NUM NUMBER(6); </li></ul></ul><ul><li>Rename Columns </li></ul><ul><ul><li>ALTER TABLE EMPLOYEE RENAME column PASSPORT_NUM TO EMP_EXTID; </li></ul></ul><ul><li>Modify Column </li></ul><ul><ul><li>ALTER TABLE EMPLOYEE MODIFY EMP_EXTID VARCHAR2(10); </li></ul></ul><ul><li>Drop Column </li></ul><ul><ul><li>ALTER TABLE EMPLOYEE DROP COLUMN EMP_EXTID; </li></ul></ul>
  16. 16. Implementing Constraints <ul><li>Add Constraints </li></ul><ul><ul><li>ALTER TABLE EMPLOYEE ADD CONSTRAINT CH_SAL CHECK(EMP_SAL BETWEEN 4000 AND 7000); </li></ul></ul><ul><li>Unique Constraints </li></ul><ul><ul><li>ALTER TABLE EMPLOYEE ADD CONSTRAINT UN_ID UNIQUE(EMP_EXTID); </li></ul></ul><ul><ul><li>ALTER TABLE EMPLOYEE DISABLE CONSTRAINT UN_ID; </li></ul></ul><ul><ul><li>ALTER TABLE EMPLOYEE ENABLE CONSTRAINT UN_ID; </li></ul></ul><ul><ul><li>ALTER TABLE EMPLOYEE DROP CONSTRAINT UN_ID; </li></ul></ul><ul><li>Additional indexes </li></ul><ul><ul><li>CREATE INDEX IND_UNID ON EMPLOYEE(UN_ID); </li></ul></ul>
  17. 17. Structured Query Language <ul><li>A high language to manipulate the database </li></ul><ul><ul><li>Data Description Language </li></ul></ul><ul><ul><li>Data Manipulation Language </li></ul></ul><ul><ul><li>Data Control Language </li></ul></ul>SQL

    Seja o primeiro a comentar

    Entre para ver os comentários

  • pikasat

    Nov. 4, 2015
  • MagdaleneWaithaka

    Jan. 22, 2021

Course Material for MBA Course on Business Information Systems


Vistos totais


No Slideshare


De incorporações


Número de incorporações