Database Concepts v1 1 1 .0

36
Database Concepts Database Database Concepts Concepts Basic / Intermediate Basic / Intermediate

Transcript of Database Concepts v1 1 1 .0

Page 1: Database Concepts v1 1 1 .0

Database ConceptsDatabase Database ConceptsConcepts

Basic / Intermediate Basic / Intermediate

Page 2: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 2

About the Author

DBCONCEPT/PPT/1205/1.0Version:

Cognizant Academy Created By:

Page 3: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 3

Questions

A welcome Break

Coding Standards

Demo Key contacts

Reference

Test your understanding

Hands on exercise

Icons used

Page 4: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 4

Course Information

Basic and IntermediateLevel

Database ConceptsPrerequisites

This course covers all basic concepts that are required to understand the database concepts and normalization rules.

Course Description

Page 5: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 5

Module Outline

Module Flow:

1.Database Concepts

Page 6: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 6

Database Concepts: Overview

Introduction:Data is factual information, especially that is used for analysis or reasoning. Data on

its own has no meaning, but it becomes information when it is interpreted. Information is a collection of facts or data.

Objective:After completing this chapter, you will be able to:

Identify the purpose of a Database Management System (DBMS)Differentiate a field from a record and a column from a rowIdentify the basic components of an Entity-Relationship modelDefine the three types of relationships that can exist between entitiesExplain the purpose of normalizationDescribe the role of a primary key Explain the purpose of a foreign key Describe how to link data in different tables using a common fieldExplain the purpose of a Structured Query Language (SQL)

Page 7: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 7

Database Terminologies

Database– A logical structure to store data– An information set with a regular structure

Database Management System (DBMS)– A software used to create and interact with a database

Page 8: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 8

DBMS Components

The following are the components of a DBMS:

• Hardware

• Software

• Data

• Users

Page 9: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 9

Database Components

The components of a database are:

• Character

• Field

• Record

• File

Page 10: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 10

Components of a DBMS

A character:• Is the basic unit of data• Can be a letter, number, or special symbol

A field:• Is a group of related characters• Represents an attribute or characteristic of an entity• Corresponds to a column in a physical database

Page 11: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 11

Components of a DBMS (Contd.)

A record:• Is a collection of fields for one specific entity• Corresponds to a row in a physical database

The file is a group of records about the same type of entity.

Page 12: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 12

Sample Record

The figure displays how a customer’s information creates a data field and a record, and then becomes part of a file.

Page 13: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 13

DBMS Terminologies

Characters, fields, and files are terms applied to real-life characteristics (or old-fashioned systems). In database terms:– Characters are bytes of data– Fields are columns– Records are rows– Files are tables

DBMS terms used in the design and physical phase can be different.

Page 14: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 14

Review of Database Design

The database design has the following phases:

• Entity-Relationship Model (E-R Model)

• Normalization

Page 15: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 15

E-R Model

The following are the features of E-R Model: • E-R model is used to depict the relationship that exists among entities.• There are many variations of E-R modeling. Oracle teaches one version, other

vendors have slightly different graphical styles. However, most conform to the basics:– Entity– Cardinality– Optionality

Page 16: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 16

E-R Model Symbols

The figure shows E-R model notations.

Page 17: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 17

Relationships

The following relationships can be included in an E-R Model:

• One-to-one

• One-to-many

• Many-to-many

Page 18: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 18

One-to-one Relationship

Each occurrence (row) of data in one entity is related to only one occurrence of data in the other entity.

Example:

Each individual has just one Social Security Number (SSN), and each SSN is assigned to only one person.

Page 19: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 19

One-to-many Relationship

Each occurrence of data in one entity can be represented by many occurrences of the data in the other entity.

Example:

A class has only one instructor, but each instructor can teach many classes.

Page 20: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 20

Many-to-many Relationship

Data can have multiple occurrences in both entities.

Example:

A student can take many classes and each class is composed of many students.

Page 21: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 21

E-R Model: Example

The figure shows an E-R model for JustLee Books.

Page 22: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 22

Normalization

Normalization:

• Determines the required tables and columns for each table

• Is a multi-step process

• Is used to reduce or control data redundancy

• Results in a proper design of a database that can be easily modified without

restructuring the database

Page 23: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 23

First-Normal Form (1NF) and Primary Key

A table is in 1NF if:

– The primary key is identified

– Repeating columns are eliminated

Primary Key• Each row in a table must be able to be uniquely identified

• In any relational database, the ability to address specific rows in a table is

required

• A primary key is one or more columns that together uniquely identifies one row in

a table

Page 24: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 24

Second-Normal Form (2NF)

A table is in 2NF if:

• Subsets of data that apply to multiple rows of the table has been removed and

have been placed in separate tables.

• Relationship between the tables have been established using foreign keys.

Page 25: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 25

Third-Normal Form (3NF)

For a table to be in 3NF, all columns must be dependent on the full primary key:

– Any columns not related to the full primary key should be removed and if required, the columns should be converted to separate tables

– ‘Key’ for other tables are in the original table

Page 26: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 26

Summary of Normalization

• 1NF: Repeating groups have been eliminated and the primary key has been

identified

• 2NF: The table is in 1NF and partial dependencies have been eliminated

• 3NF: The table is in 2NF and transitive dependencies have been eliminated

Page 27: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 27

Linking Tables

Ensure the following when linking tables:

• Once tables are normalized, link certain tables

• Tables are linked through a common field

A common field is usually a primary key in one table and the foreign key in the other

table.

Page 28: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 28

Linking Tables

The figure shows JustLeeBook’s table structure after normalization.

Page 29: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 29

Structured Query Language (SQL)

Structured Query Language is:

• A data sub-language

• Used for:– Creating or modifying tables– Adding data to tables– Editing data in tables– Retrieving data from tables

Page 30: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 30

Structured Query Language (SQL)

SQL is composed of the following database languages:

1. Data Definition Language (DDL): SQL statements that are used to create or

destroy objects

2. Data Manipulation Language (DML): SQL statements that are used to query or

update data in tables

3. Data Control Language (DCL): SQL statements that are used to grant and

revoke privileges

Page 31: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 31

Allow time for questions from participants

Page 32: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 32

1. What is the difference between character, field, record and file? Give an example for each.

2. What is meant by data?3. What is the purpose of database? Give two examples?4. What is the difference between DBMS and RDBMS?5. Is Oracle a DBMS/RDBMS system?6. What is the full form of ERD?7. What is the difference between an entity and attribute?8. What are the different type of relationships you come across in an E/R model?9. Why a designer follows normalization during designing an application?10. What is meant by 1NF, 2NF, and 3NF? Give example for each?

Test Your Understanding

Page 33: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 33

Database Concepts: Summary

• The following are the components of a DBMS:– Hardware– Software– Data– Users

• The components of a database are:– Character– Field– Record– File

• Normalization: • Determines the required tables and columns for each table• Is a multi-step process• Is used to reduce or control data redundancy• Results in a proper design of a database that can be easily modified without

restructuring the database

Page 34: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 34

Database Concepts: Summary

The following relationships can be included in an E-R Model:

– One-to-one

– One-to-many

– Many-to-manyEnsure the following when linking tables:– Once tables are normalized, link certain tables– Tables are linked through a common field

Structured Query Language is:– A data sub-language – Used for:

→ Creating or modifying tables→ Adding data to tables→ Editing data in tables→ Retrieving data from tables

Page 35: Database Concepts v1 1 1 .0

©Copyright 2004, Cognizant Academy, All Rights Reserved 35

Database Concepts: Next Step

The following items will provide more information on the subjects covered inthis Module:

Reference Topic or Module

DescriptionResource Type

http://www.learndatamodeling.com/URL

Database Concepts Absolute Beginner's Guide to Databases

Book

Disclaimer: Parts of the content of this course is based on the materials available from the Web sites and books listed above. The materials that can be accessed from linked sites are not maintained by Cognizant Academy and we are not responsible for the contents thereof. All trademarks, service marks, and trade names in this course are the marks of the respective owner(s).

Page 36: Database Concepts v1 1 1 .0

Congratulations!You have successfully

completedDatabase Concepts

Congratulations!Congratulations!You have successfully You have successfully

completedcompletedDatabase ConceptsDatabase Concepts