19
CSCI 253 -- Database Modelling 1 Database Modelling Dr. Awad Khalil Dr. Awad Khalil Computer Science Department Computer Science Department AUC AUC

Database Modelling

Embed Size (px)

DESCRIPTION

Database Modelling. Dr. Awad Khalil Computer Science Department AUC. Content. Database Structure The Three-Layer Architecture Data Models Classification of DBMSs. Database Structure. - PowerPoint PPT Presentation

Citation preview

Page 1: Database Modelling

CSCI 253 -- Database Modelling 1

Database Modelling

Dr. Awad KhalilDr. Awad Khalil

Computer Science DepartmentComputer Science Department

AUCAUC

Page 2: Database Modelling

CSCI 253 -- Database Modelling 2

Content

Database StructureDatabase Structure

The Three-Layer ArchitectureThe Three-Layer Architecture

Data ModelsData Models

Classification of DBMSsClassification of DBMSs

Page 3: Database Modelling

CSCI 253 -- Database Modelling 3

Database Structure

A A database structuredatabase structure is the description and definition is the description and definition of all basic structures such as simple conceptual files, of all basic structures such as simple conceptual files, datatypes, relationships, and constraints that should datatypes, relationships, and constraints that should hold on the data. hold on the data.

In any data model it is important to distinguish between In any data model it is important to distinguish between the description of the database (the description of the database (SchemaSchema) and the ) and the database itself (database itself (InstanceInstance).).

  

Page 4: Database Modelling

CSCI 253 -- Database Modelling 4

Database Schema

The description of a The description of a database is called thedatabase is called the database schemadatabase schema (or the (or the meta-datameta-data).).

A database schema A database schema is specified during is specified during database design and database design and is not expected to is not expected to change frequently.change frequently.

Page 5: Database Modelling

CSCI 253 -- Database Modelling 5

A Database Schema in SQLCREATE TABLECREATE TABLE EMPLOYEE EMPLOYEE(FNAME(FNAME VARCHAR(15) VARCHAR(15) NOT NULL,NOT NULL,MINITMINIT CHAR,CHAR,LNAMELNAME VARCHAR(15) VARCHAR(15) NOT NULL,NOT NULL,SSNSSN SSN_TYPE SSN_TYPE NOT NULL,NOT NULL,BDATEBDATE DATEDATEADDRESSADDRESS VARCHAR(30),VARCHAR(30),SEXSEX CHAR,CHAR,SALARYSALARY DECIMAL(10,2),DECIMAL(10,2),SUPERSSNSUPERSSN SSN_TYPE,SSN_TYPE,DNODNO INTINT NOT NULL,NOT NULL,PRIMARY KEYPRIMARY KEY (SSN), (SSN),FOREIGN KEYFOREIGN KEY (SUPERSSN) (SUPERSSN) REFERENCESREFERENCES

EMPLOYEE(SSN),EMPLOYEE(SSN),FOREIGN KEYFOREIGN KEY (DNO) (DNO) REFERENCES REFERENCES

DEPARTMENT(DNUMBER));DEPARTMENT(DNUMBER));CREATE TABLECREATE TABLE DEPARTMENT DEPARTMENT(DNAME(DNAME VARCHAR(15) VARCHAR(15) NOT NULL,NOT NULL,DNUMBERDNUMBER INT,INT, NOT NULL,NOT NULL,MGRSSNMGRSSN SSN_TYPESSN_TYPE NOT NULL,NOT NULL,MGRSTARTDATEMGRSTARTDATE DATEDATEPRIMARY KEYPRIMARY KEY (DNUMBER), (DNUMBER),UNIQUEUNIQUE (DNAME) (DNAME)FOREIGN KEYFOREIGN KEY (MGRSSN) (MGRSSN) REFERENCES REFERENCES

EMPLOYEE(SSN));EMPLOYEE(SSN));CREATE TABLECREATE TABLE DEPT_LOCATIONS DEPT_LOCATIONS(DNUMBER(DNUMBER INTINT NOT NULL,NOT NULL,DLOCATIONDLOCATION VARCHAR(15) VARCHAR(15) NOT NULL,NOT NULL,PRIMARY KEYPRIMARY KEY (DNUMBER, DLOCATION), (DNUMBER, DLOCATION),FOREIGN KEYFOREIGN KEY (DNUMBER) (DNUMBER) REFERENCES REFERENCES

DEPARTMENT(DNUMBER));DEPARTMENT(DNUMBER));

CREATE TABLECREATE TABLE PROJECT PROJECT(PNAME(PNAME VARCHAR(15)VARCHAR(15)

NOT NULL,NOT NULL,PNUMBERPNUMBER INTINT

NOT NULL,NOT NULL,PLOCATIONPLOCATION VARCHAR(15)VARCHAR(15)DNUMDNUM INTINT

NOT NULL,NOT NULL,PRIMARY KEYPRIMARY KEY (PNUMBER), (PNUMBER),UNIQUEUNIQUE (PNAME) (PNAME)FOREIGN KEYFOREIGN KEY (DNUM) (DNUM) REFERENCES REFERENCES

DEPARTMENT(DNUMBER));DEPARTMENT(DNUMBER));CREATE TABLECREATE TABLE WORKS_ON WORKS_ON(ESSN(ESSN SSN_TYPESSN_TYPE NOT NULL,NOT NULL,PNOPNO INTINT NOT NULL,NOT NULL,HOURSHOURS DECIMAL(3,1) DECIMAL(3,1) NOT NULL,NOT NULL,PRIMARY KEYPRIMARY KEY (ESSN, PNO), (ESSN, PNO),FOREIGN KEYFOREIGN KEY (ESSN) (ESSN) REFERENCES REFERENCES EMPLOYEE(SSN),EMPLOYEE(SSN),FOREIGN KEYFOREIGN KEY (PNO) (PNO) REFERENCES REFERENCES PROJECT(PNUMBER));PROJECT(PNUMBER));CREATE TABLECREATE TABLE DEPENDENT DEPENDENT (ESSN(ESSN SSN_TYPE SSN_TYPE NOT NULL,NOT NULL, DEPENDENT_NAME VARCHAR(15) DEPENDENT_NAME VARCHAR(15) NOT NULL,NOT NULL, SEXSEX CHAR,CHAR,    BDATE BDATE DATE,DATE,    RELATIONSHIPRELATIONSHIP VARCHAR(8)VARCHAR(8)    PRIMARY KEYPRIMARY KEY (ESSN, DEPENDENT_NAME), (ESSN, DEPENDENT_NAME), FOREIGN KEYFOREIGN KEY (ESSN) (ESSN) REFERENCES REFERENCES EMPLOYEE(SSN));EMPLOYEE(SSN));

Page 6: Database Modelling

CSCI 253 -- Database Modelling 6

Database State (Instance)

The data in the The data in the database at a database at a particular moment particular moment of time is called the of time is called the database state database state ((oror instance). instance).

Page 7: Database Modelling

CSCI 253 -- Database Modelling 7

The Three-Layer Architecture

E xte rna lV ie w 1

E xte rna lV ie w n

C o nc e p tu a l S c he m a

Inte rna l S c he m a

S to re d D a ta b a se

E n d U s e rs

E xte rna l Le v e l

C o nc e p tu a l Le v e l

Inte rna l Le v e l

externa l/concep tua lm app ing

concep tua l/in terna lm app ing

Page 8: Database Modelling

CSCI 253 -- Database Modelling 8

Data Models

A A data modeldata model is a set of concepts that can be used to is a set of concepts that can be used to describe a database structure.describe a database structure.

High-level(c o nc ep tual)Data M o d els

Imp lementatio nData M o d els

Lo w-level(p hys ic al)

Data M o d els

D a ta M o d e ls

Hierarc hic alR elatio nal Netwo rk O b jec t-o riented

Page 9: Database Modelling

CSCI 253 -- Database Modelling 9

DBMS Generations

Page 10: Database Modelling

CSCI 253 -- Database Modelling 10

Data Independence

Data independenceData independence is the capacity to change the is the capacity to change the schema at one level of a database system without having schema at one level of a database system without having to change the schema at the next higher level. defined:to change the schema at the next higher level. defined:

Logical data independenceLogical data independence is the capacity to change is the capacity to change the conceptual schema without having to change the conceptual schema without having to change external schemas or Logical data application programs.external schemas or Logical data application programs.

Physical data independencePhysical data independence is the capacity to is the capacity to change the internal schema without having to change change the internal schema without having to change the conceptual (or external) schemas.the conceptual (or external) schemas.

Page 11: Database Modelling

CSCI 253 -- Database Modelling 11

Classification of DBMSs

Classification according to Data ModelClassification according to Data Model

D B M S s

Hierarc hic alR elatio nal Netwo rk O b jec t-o riented

Page 12: Database Modelling

CSCI 253 -- Database Modelling 12

The Relational Data Model

The The relationalrelational data model represents the database as a data model represents the database as a collection of tables, where each table can be stored as collection of tables, where each table can be stored as separate file.separate file.

Examples of commercial relational DBMSs:Examples of commercial relational DBMSs: DB2 DB2 from IBMfrom IBM   ORACLE from Oracle CorporationORACLE from Oracle Corporation   Informix Informix from Informixfrom Informix   SyBase SyBase from OpenSoftfrom OpenSoft   SQL ServerSQL Server from Microsoft from Microsoft   MS-ACCESS MS-ACCESS from Microsoftfrom Microsoft

Page 13: Database Modelling

CSCI 253 -- Database Modelling 13

An Example of a Relational Database

Page 14: Database Modelling

CSCI 253 -- Database Modelling 14

The Network Data model

The The networknetwork data model data model represents data represents data as a record as a record types. An types. An example of a example of a network network model is model is known as the known as the CODASYL CODASYL DBTG model.DBTG model.

Page 15: Database Modelling

CSCI 253 -- Database Modelling 15

The Hierarchical Data model

The The hierarchicalhierarchical data model data model represents data represents data as hierarchical as hierarchical tree structure. tree structure. Each Each hierarchical hierarchical represents a represents a number of number of related records.related records.

Page 16: Database Modelling

CSCI 253 -- Database Modelling 16

The Object-Oriented Data model

The The object-orientedobject-oriented data model defines a data model defines a database in terms of database in terms of objects, their properties, objects, their properties, and their operations. and their operations. Objects with the same Objects with the same structure and behavior structure and behavior belong to a class, and belong to a class, and classes are organized classes are organized into hierarchies or a into hierarchies or a cyclic graphs. The cyclic graphs. The operations of each class operations of each class are specified in terms of are specified in terms of predefined procedures predefined procedures called called methodsmethods..

Experimental Experimental OOOO prototypes prototypesThe ORION system developed at MCC,The ORION system developed at MCC,The OpenOODB system at Texas Instruments,The OpenOODB system at Texas Instruments,The IRIS system developed at HP laboratories,The IRIS system developed at HP laboratories,The ODE system at ATT Bell Labs, andThe ODE system at ATT Bell Labs, andThe ENCORE/ObServer project at Brown The ENCORE/ObServer project at Brown

University.University.

Commercially available OO systemsCommercially available OO systemsGEM-STONE/OPALGEM-STONE/OPAL of SerioLogic, of SerioLogic,ONTOS ONTOS of Ontologic,of Ontologic,Objectivity Objectivity of Objectivity Inc.,of Objectivity Inc.,VersantVersant of Versant Technologies, of Versant Technologies,ObjectStoreObjectStore of Object Design, and, of Object Design, and,O2O2 of O2 Technology. of O2 Technology.

Page 17: Database Modelling

CSCI 253 -- Database Modelling 17

Classification of DBMSs

Classification according to Number of UsersClassification according to Number of Users

Single user systems support only one user at a systems support only one user at a time and are mostly used with personal computers.time and are mostly used with personal computers.

Multiuser systems, which include the majority of systems, which include the majority of DBMSs, support many users concurrently.DBMSs, support many users concurrently.

Page 18: Database Modelling

CSCI 253 -- Database Modelling 18

Classification of DBMSs

Classification according to Number of SitesClassification according to Number of Sites

Centralized DBMS where the data is stored at a where the data is stored at a single computer site. Most DBMSs are centralized. single computer site. Most DBMSs are centralized. A centralized DBMS can support multiple users, but A centralized DBMS can support multiple users, but the DBMS and the database themselves reside totally the DBMS and the database themselves reside totally at a single computer site.at a single computer site.

Distributed DBMS (DDBMS) can have the actual can have the actual database and DBMS software distributed over many database and DBMS software distributed over many sites, connected by a computer network. Many sites, connected by a computer network. Many DDBMSs use a DDBMSs use a client-serverclient-server architecture. architecture.

Page 19: Database Modelling

CSCI 253 -- Database Modelling 19

Thank you