LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.

Slides:



Advertisements
Similar presentations
The Relational Model System Development Life Cycle Normalisation
Advertisements

Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Chapter 2 Database Environment.
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
1 Minggu 2, Pertemuan 3 The Relational Model Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
1 Chapter 2 Database Environment. 2 Objectives of Three-Level Architecture u All users should be able to access same data u User’s view immune to changes.
1 Pertemuan 04 MODEL RELASIONAL Matakuliah: >/ > Tahun: > Versi: >
Thomas Connolly and Carolyn Begg’s
Lecture Two Database Environment Based on Chapter Two of this book:
Relational Database Management System A type of database in which records are stored in relational form is called relational database management system.
1 Chapter 2 Database Environment. 2 Chapter 2 - Objectives u Purpose of three-level database architecture. u Contents of external, conceptual, and internal.
Database Architecture The Relational Database Model.
Database Environment 1.  Purpose of three-level database architecture.  Contents of external, conceptual, and internal levels.  Purpose of external/conceptual.
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
CSC271 Database Systems Lecture # 6. Summary: Previous Lecture  Relational model terminology  Mathematical relations  Database relations  Properties.
Relational Model & Relational Algebra. 2 Relational Model u Terminology of relational model. u How tables are used to represent data. u Connection between.
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
Information storage: Introduction of database 10/7/2004 Xiangming Mu.
Chapter 4 The Relational Model Pearson Education © 2014.
© Pearson Education Limited, Chapter 2 The Relational Model Transparencies.
Relational Model Session 6 Course Name: Database System Year : 2012.
Chapter 4 The Relational Model.
Chapter 3 The Relational Model Transparencies Last Updated: Pebruari 2011 By M. Arief
Chapter 2 CIS Sungchul Hong
CSC271 Database Systems Lecture # 4.
Database Technical Session By: Prof. Adarsh Patel.
CST203-2 Database Management Systems Lecture 2. One Tier Architecture Eg: In this scenario, a workgroup database is stored in a shared location on a single.
Module 3: The Relational Model.  Overview Terminology Relational Data Structure Mathematical Relations Database Relations Relational Keys Relational.
Chapter 3 The Relational Model. 2 Chapter 3 - Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between.
10/17/2012ISC471/HCI571 Isabelle Bichindaritz 1 Technologies Databases.
1 The Relational Database Model. 2 Learning Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical.
1 Chapter 1 Introduction. 2 Introduction n Definition A database management system (DBMS) is a general-purpose software system that facilitates the process.
9/7/2012ISC329 Isabelle Bichindaritz1 The Relational Database Model.
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
The Relational Model Pertemuan 03 Matakuliah: M0564 /Pengantar Sistem Basis Data Tahun : 2008.
Relational Database. Database Management System (DBMS)
DataBase Management System What is DBMS Purpose of DBMS Data Abstraction Data Definition Language Data Manipulation Language Data Models Data Keys Relationships.
8/31/2012ISC329 Isabelle Bichindaritz1 Database Environment.
Chapter 2 THE DATABASE ENVIRONMENT Introduction to Databases: ANSI-SPARC Architecture Data independence Data models Relational database concepts Introduction.
Module 2: Database Environment
Database Environment Session 2 Course Name: Database System Year : 2013.
1 Chapter 1 Introduction to Databases Transparencies.
12/2/2015CPSC , CPSC , Lecture 41 Relational Model.
The relational model A data model (in general) : Integrated collection of concepts for describing data (data requirements). Relational model was introduced.
The Relational Model. 2 Relational Model Terminology u A relation is a table with columns and rows. –Only applies to logical structure of the database,
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
1 Chapter 2 Database Environment Pearson Education © 2009.
Chapter 3: Relational Databases
The Relational Model © Pearson Education Limited 1995, 2005 Bayu Adhi Tama, M.T.I.
CSCI 6315 Applied Database Systems Review for Midterm Exam I Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
Chapter 4 The Relational Model Pearson Education © 2009.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
COP Introduction to Database Structures
Chapter 2 Database Environment.
Chapter 2 Database Environment.
Chapter 2 Database Environment Pearson Education © 2009.
Chapter 2 Database Environment.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
The Relational Model Transparencies
Data Model.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 2 Database Environment Pearson Education © 2009.
Chapter 2 Database Environment Pearson Education © 2009.
INTRODUCTION A Database system is basically a computer based record keeping system. The collection of data, usually referred to as the database, contains.
Presentation transcript:

LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML

Database Models  The DDL of a given DBMS is too low level to describe an organisations data requirements in a readily available manner.  A data model may be defined as; An integrated collection of concepts for describing data (real world objects and events), relationships between data, and constraints on the data in an organization.  Provides basic notations and concepts that will allow database designers and end-users to unambiguously and accurately communicate their understanding of the organisational data. 2Database Models

3  The process of data modelling allows one to see the options provided by possible representations and to predict the effects of our decisions. If not done well, serious problems may be caused later in the development process.  Data Model comprises: A structural part A manipulative part Possibly a set of integrity rules  Purpose To represent data in an understandable way.

Database Model cont’d  There are different database models which include: Relational ERD: mainly used in design Object based: Object oriented and object-relational Semi-structured e.g. XML Network and Hierarchical database models.  These fall under one of the following categories of data models: Object-based Record-based Physical 4Database Models

Database Models cont’d Object-based Data Models These use concepts based on entities, attributes and relationships. Some examples include; Entity-Relationship Semantic Functional Object-Oriented 5Database Models

Database models cont’d Record-based Data Models Database consists of a number of fixed-format records possibly of differing types. Each record type is defined by a fixed number of fields, each with a fixed length These include; Relational, Network and Hierarchical data models. Database Models1.6

Database models cont’d Relational Data Model  Based on mathematical relations  Data and relationships are represented as tables, each having uniquely identified columns Network Data Model  Data is represented as a collection of records  Relationships are represented as sets  The sets are implemented as pointers  A graphical representation is used. 7Database Models

Database models cont’d Hierarchical Data Model  Restricted type of network model  A tree-graph representation is used (records/segments as nodes and sets as edges.)  A node is allowed to have only one parent Physical Data Models Present how data is stored in a computer e.g. structures of records. 8Database Models

Relational Database Concepts1.9 Example of a Relational DB A company needs to store information on departments and employees. Each table contains data that describes exactly one entity - a thing of significance about which information needs to be known.

Relational Database Concepts1.10 Relational Database Concepts  Relation – a table composed of rows and columns  Attribute – a column of a relation.  Tuple – a row of a relation.  Cell – an intersection of a row and a column of a relation.  Domain – a set of allowable values for one or more attributes.  Null – a value that is unknown or not applicable in a given cell.

Relational Database Concepts1.11  Degree – number of attributes for a given relation.  Cardinality – number of tuples for a given relation.  Relation schema – a named collection of attributes and any data constraints. Representation of a department relation schema DEPARTMENT (DeptNo, DName, Loc) Data Constraints: A department name value must never be repeated. Relational Database Concepts Cont’d

Relational Database Concepts1.12 Instances of Branch and Staff (part) Relations

Relational Database Concepts1.13 Examples of Attribute Domains

Relational Database Concepts1.14 Alternative Terminology for Relational Model

Relational Database Concepts1.15  Relational database – a finite set of relational schemas. Representation of a relational database schema for a company that stores information on departments and employees. DEPARTMENT (DeptNo, DName, Loc) EMPLOYEES (EmpNo, EName, Job, Mgr, HireDate, Sal, Comm, DeptNo) Data Constraints: A department name value must never be repeated. No employee should earn a salary that is more than Relational Database Concepts Cont’d

Relational Database Concepts1.16  Primary key – attribute(s) that is selected to identify tuples uniquely within a relation. A primary key value must be unique and cannot be null.  Unique key – attribute(s) that contains distinct values but can also accommodate null values.  Foreign key – attribute(s) within one relation that matches attribute(s) of another or same relation. A foreign key value must match the primary/unique key value of some tuple in its parent relation or the foreign key value must be wholly null. Relational Database Concepts Cont’d

Relational Database Concepts1.17 Properties of Relations:  Uniqueness of relation names in a relational database schema.  Uniqueness of attributes for a given relation  Uniqueness of tuples for a given relation  Order of attributes / tuples for a given relation is not significant  Values of an attribute are from the same domain.  A cell of a relation contains exactly one atomic (single) value. Relational Database Concepts Cont’d

Relational Database Concepts1.18 Relational Keys  Super key An attribute, or a set of attributes, that uniquely identifies a tuple within a relation.  Candidate Key Superkey (K) such that no proper subset is a superkey within the relation. In each tuple of R, values of K uniquely identify that tuple (uniqueness). No proper subset of K has the uniqueness property (irreducibility).

Relational Database Concepts1.19 Relational Keys Cont’d  Primary Key Candidate key selected to identify tuples uniquely within relation.  Alternate Keys Candidate keys that are not selected to be primary key.  Foreign Key Attribute, or set of attributes, within one relation that matches candidate key of some (possibly same) relation.

Relational Database Concepts1.20 Relational Integrity  Null Represents value for an attribute that is currently unknown or not applicable for tuple Deals with incomplete or exceptional data. Represents the absence of a value and is not the same as zero or spaces, which are values.  Enterprise Constraints Additional rules specified by users or database administrators.

Relational Database Concepts1.21 Relational Integrity Cont’d  Entity Integrity In a base relation, no attribute of a primary key can be null. (Please note that this is a correct statement: because a primary key may be formed of more than one attribute.)  Referential Integrity If foreign key exists in a relation, either foreign key value must match a candidate key value of some tuple in its home relation or foreign key value must be wholly null.

Introduction Database Languages Database Languages  Database Languages are known as data Sublanguages.  DBMSs have a facility for embedding the sublanguage in a high-level programming language e.g. C, C++, Java Or VB. The high-level language is then known as a host Language.  Most data sublanguages also provide interactive commands that can be input directly from a terminal.

Introduction Database Languages Database languages Cont’d  A data sublanguage consists of two parts: Data definition Language (DDL)  Used to specify the database schema. Data Manipulation Language (DML)  Used to read and update the database.

Data Definition Languages Data Definition Language (DDL)  This is a language that allows the DBA or user to describe and name the entities, attributes and relationships required for the application, together with any associated integrity and security constraints (Begg & Connolly, 2002)  DDL is not only used to specify new database schemas but also to modify exiting ones. A database schema is a logical grouping of objects that belong to a user.  All created objects / structures (such as tables, views, indexes) are stored in a database schema.

Data Definition Languages DDL cont’d  Relation DB schema objects are created and maintained by using SQL DDL statements (such as CREATE, ALTER, DROP).  The result of compiling DDL statements is a set of tables stored in special files collectively called the system catalog. The system catalog may also be referred to as a data dictionary.

Data Definition Languages DDL Cont’d  The data dictionary integrates the meta-data; definitive information about the structure is recorded in a data dictionary. For example: definitions about the records, data items and other objects of interest to users or required by the DBMS.  The DBMS consults the data dictionary before accessing or manipulating the data.  Example of DDL SQL statement: CREATE, ALTER, DROP, RENAME, TRUNCATE

Data Manupulation lanaguages Data Manipulation Language (DML)  This is a language that provides a set of operations to support the basic data manipulation operations on the data held in the database.  Some of the operations include: Insertion of new data into the database Modification of data stored in the database Retrieval of data contained in the database (Query language). Deletion of data from the database.

Data Manupulation lanaguages DML Cont’d  Procedural DML This is a language that allows the user to tell the system what data is needed and exactly how to retrieve the data; allows user to tell system exactly how to manipulate data.  Non-Procedural DML allows user to state what data is needed rather than how it is to be retrieved.

Data Manupulation lanaguages DML Cont’d  Examples of DML SQL statements; INSERT UPDATE DELETE MERGE