Relational Database Design

Slides:



Advertisements
Similar presentations
What is a Database By: Cristian Dubon.
Advertisements

The Relational Model and Relational Algebra Nothing is so practical as a good theory Kurt Lewin, 1945.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
The Relational Model. Introduction Introduced by Ted Codd at IBM Research in 1970 The relational model represents data in the form of table. Main concept.
Introduction to Structured Query Language (SQL)
Introduction to Structured Query Language (SQL)
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
Introduction to Structured Query Language (SQL)
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Oracle Data Definition Language (DDL)
The Relational Model These slides are based on the slides of your text book.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Database Technical Session By: Prof. Adarsh Patel.
Chapter 9 Designing Databases Modern Systems Analysis and Design Sixth Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
Concepts and Terminology Introduction to Database.
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
FALL 2004CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Chapter 10 Normalization Pearson Education © 2009.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 16 Using Relational Databases.
1 DBS201: More on SQL Lecture 3. 2 Agenda How to use SQL to update table definitions How to update data in a table How to join tables together.
Constraints Lesson 8. Skills Matrix Constraints Domain Integrity: A domain refers to a column in a table. Domain integrity includes data types, rules,
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,
Session 1 Module 1: Introduction to Data Integrity
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
CSC314 DAY 8 Introduction to SQL 1. Chapter 6 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SQL OVERVIEW  Structured Query Language  The.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
 CONACT UC:  Magnific training   
Constraints Advanced Database Systems Dr. AlaaEddin Almabhouh.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
1 Agenda TMA02 M876 Block 4. 2 Model of database development data requirements conceptual data model logical schema schema and database establishing requirements.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
Getting started with Accurately Storing Data
Fundamentals of DBMS Notes-1.
Logical Database Design and the Rational Model
Relational Database Design
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
SQL Creating and Managing Tables
Quiz Questions Q.1 An entity set that does not have sufficient attributes to form a primary key is a (A) strong entity set. (B) weak entity set. (C) simple.
Chapter 4 Relational Databases
ORACLE SQL Developer & SQLPLUS Statements
Chapter 9 Designing Databases
SQL Creating and Managing Tables
Chapter 8 Working with Databases and MySQL
Normalization Referential Integrity
Relational Database.
SQL Creating and Managing Tables
Chapter 4 The Relational Model Pearson Education © 2009.
Practical Database Design and Tuning
A Guide to SQL, Eighth Edition
Normalization Normalization theory is based on the observation that relations with certain properties are more effective in inserting, updating and deleting.
Chapter 4 The Relational Model Pearson Education © 2009.
Unit 7 Normalization (表格正規化).
Chapter 4 The Relational Model Pearson Education © 2009.
Contents Preface I Introduction Lesson Objectives I-2
國立臺北科技大學 課程:資料庫系統 2015 fall Chapter 14 Normalization.
Chapter 8 Advanced SQL.
Database Design: Relational Model
Chapter 4 The Relational Model Pearson Education © 2009.
Database Systems: Design, Implementation, and Management Tenth Edition
Presentation transcript:

Relational Database Design Structured Query Language (SQL)

A Database Structure

Database Building Blocks

Structure of a Relational Database

Training Database Schema

Normalization Theory (1 of 2) Normalization is an integral technique of a bottom-up approach. Normalization theory is used as a design verification technique in a top-down approach.

Normalization Theory (2 of 2) “A record is in second and third normal form if every field is either part of the key or provides a (single-valued) fact about exactly the whole key and nothing else” “A table is in third normal form if every non-key field depends upon The primary key. The whole key. And nothing but the key”

Scope of Normalization (1 of 4) This theory is applicable to any DBMS. Not just relational.

Scope of Normalization (2 of 4) It is applicable to the design of simple files as well.

Scope of Normalization (3 of 4) Normalization theory is a process of decomposing tables or records from an un-normalized form to a normalized form. Each decomposition reduces the possibility of errors or anomalies occurring during database update processing.

Scope of Normalization (4 of 4) Applying the normalization process. Tables are transformed to a higher normal form. Note that 5th normal form (5NF) is a theoretical ideal.

Benefit and Cost of Normalization (1 of 4) The ultimate benefit derived from applying normalization theory is a stable design. Reducing the chance of update errors.

Benefit and Cost of Normalization (2 of 4) In order to implement a database through the normalization process. One must have a real understanding of the semantics (meaning) of each data item. This forces the database designer to effectively communicate with the users of the database.

Benefit and Cost of Normalization (3 of 4) Users understand clearly the meaning of data in relations so they correctly formulate queries.

Benefit and Cost of Normalization (4 of 4) There is extra an effort of joining and tables.

Functional Dependence (1 of 2) Given a relation R. Attribute Y of R is functionally dependent on attribute X of R if each X-value of R has associated with it precisely one Y-value of R (at any one time). Attributes X and Y may be composite.

Functional Dependence (2 of 2) Functional dependence means: "You tell me X and I'll tell you Y" Notation: R.X  R.Y Examples: STUDNO  SNAME STUDNO SAGE COURSENO CNAME POLICYNO  NAME-OF-INSURED CLAIMNO  POLICYNO

Functional Dependence Functional dependence is not limited to a single data item. It can be extended to a collection of fields. Notation: A,BC

Functional dependence is a semantic notion. An understanding of the meaning of data items in the application domain is required. Applying functional dependence enables the designer to identify keys.

Candidate key If a field uniquely identifies every other field in a given table. It is a candidate key. Alternatively: If every field in a table is functionally dependent on field k. Then k is a candidate key.

Composite key Sometimes a candidate key is a composite key A single data item is not sufficient to determine the other data items of the record.

First Normal Form For a table to be in First Normal Form (1NF). All data item values must be atomic. This means that there are no repeating groups. In a table. Every row-column intersection holds a single value. Not a set of values.

Unnormalized table.

First Normal form

Second Normal form

Third Normal form

Transitive Dependency

Same category of information Tables Header row Row Same category of information Column Related information

Information retrieved Databases Database Table 1 Table 2 Table 3 Table 4 Information searched Database objects Information retrieved

Databases (Cont.)

Databases (Cont.) Default databases Customized databases

Servers Higher performance No user Manage resource Provide services Network Client 1 Client 2 Client 3 Server

Clients Client 1 Client 2 Client 3 Server Connected to the same network as the server Displays result Requests the service of the server

characters are allowed Data Types Alphanumeric values Only numeric values are allowed Data types characters are allowed Numeric values

Datatypes

SSMS Shortcuts

The Inner Join Tables to be joined Keyword entered between two table names Condition containing the comparison operator Tables to be joined Records that have matching values

The Outer Join Column used to join tables Keyword entered between two table names ON clause containing the condition Column used to join tables Matching rows from both tables Rows from one table Output after joining two tables

SQL Logical Query Processing Steps Clause Order Logical Processing Steps SELECT FROM JOIN____ON____ WHERE GROUP BY HAVING ORDER BY FROM ON OUTER WHERE GROUP BY CUBE | ROLLUP HAVING SELECT DISTINCT ORDER BY TOP

The CREATE TABLE Statement Table name Restricts storage of null value Size enclosed within parentheses Datatype and size specified Column names and definitions

Table Design Columns Rows Column header

Data Integrity All values are valid and can be used further qty<225 Column contains valid data Linked columns have matching values Each record is unique

Constraints Qty>0 Column-level constraint Defines rules to test column value Domain integrity implemented

Primary Keys Primary key Uniquely identifies each column Cannot store null or duplicate values

PRIMARY KEY Constraints Constraint name Prevents record duplication Creates primary key on this column Table-level constraint Column name chosen as primary key

UNIQUE Constraints Can accept null values Column-level Implements uniqueness in values stored Can accept null values

Foreign Keys Foreign key Can store Primary key of duplicate values Stores matching values Links records Primary key of referenced table Referenced table

FOREIGN KEY Constraints Defined when creating a table Referenced table name Column-level constraint Referenced column Cannot be modified once created without being deleted Foreign key name Creates the foreign key Table-level constraint

column-level constraint DEFAULT Constraints Specified when creating a table Specified only as a column-level constraint Specifies a default value for a column Value must correspond to the datatype of the column

value based on condition CHECK Constraints Validates column value based on condition Executed in the order specified Multiple expressions linked Column-level CHECK constraint Table-level Logical expression

The ALTER TABLE Statement Modifies table structure Adds a column Modifies column definitions Adds a constraint Drops a column Drops a constraint

Sparse Columns Table name Sparse attribute for the ‘deptno’ column Column definition Code to be inserted here .