overview of database concept

40
Overview of Database Concepts

Upload: gourav-kottawar

Post on 21-Mar-2017

226 views

Category:

Education


0 download

TRANSCRIPT

Page 1: overview of database concept

Overview of Database Concepts

Page 2: overview of database concept

Chapter Objectives

• Identify the purpose of a database management system (DBMS)

• Distinguish a field from a record and a column from a row

• Identify the basic components of an Entity-Relationship Model

• Define the three types of relationships that can exist between entities

Page 3: overview of database concept

Chapter Objectives

• Identify the problem associated with many-to-many relationships and the appropriate solutions

• Explain the purpose of normalization• Describe the role of a primary key • Identify partial dependency and transitive

dependency in the normalization process

Page 4: overview of database concept

Chapter Objectives

• Explain the purpose of a foreign key • Determine how to link data in different

tables through the use of a common field• Explain the purpose of a structured query

language (SQL)

Page 5: overview of database concept

Database Terminology

• Database – logical structure to store data

• Database Management System (DBMS) – software used to create and interact with the database

Page 6: overview of database concept

Database Components

• Character• Field• Record• File

Page 7: overview of database concept

Database Components - Character

• Basic unit of data• Can be a letter, number, or special symbol

Page 8: overview of database concept

Database Components - Field

• A group of related characters• Represents an attribute or characteristic of

an entity• Corresponds to a column in the physical

database

Page 9: overview of database concept

Database Components - Record

• A collection of fields for one specific entity• Corresponds to a row in the physical

database

Page 10: overview of database concept

Database Components - File

• A group of records about the same type of entity

Page 11: overview of database concept

Components Example

Page 12: overview of database concept

Review of Database Design

• Systems Development Life Cycle (SDLC)• Entity-Relationship Model (E-R Model)• Normalization

Page 13: overview of database concept

Systems Development Life Cycle (SDLC)

• Systems investigation – understanding the problem

• Systems analysis – understanding the solution

• Systems design – creating the logical and physical components

Page 14: overview of database concept

Systems Development Life Cycle (SDLC)

• Systems implementation – placing completed system into operation

• Systems maintenance and review – evaluating the implemented system

Page 15: overview of database concept

Entity-Relationship Model (E-R Model)

• Used to depict the relationship that exists among entities

Page 16: overview of database concept

E-R Model Symbols

Page 17: overview of database concept

Relationships

• The following relationships can be included in an E-R Model:– One-to-one– One-to-many– Many-to-many

Page 18: overview of database concept

One-to-one Relationship

• Each occurrence of data in one entity is represented by 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 just one person

Page 19: overview of database concept

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: overview of database concept

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: overview of database concept

Example E-R Model

Page 22: overview of database concept

Normalization

• Determines required tables and columns for each table

• Multi-step process allows designer to take the raw data to be collected about an entity

• Used to reduce or control data redundancy

Page 23: overview of database concept

Attributes of Books• isbn : a value string used to identify any book.• Title: Book’s title• Publication Date: A value of DATE type.• Cost: Publisher’ price• Retail: Sale’s price.• Category: Computer, Fiction Science, etc.• Publisher: Publisher’ house.• Contact: Sale representative.

Page 24: overview of database concept

Representation of Books

Page 25: overview of database concept

Unnormalized Data

Contains repeating groups in the Author column in the BOOKS table

Page 26: overview of database concept

First-Normal Form (1NF)

• Primary key is identified. A Primary key is a field that serves to uniquely identify each record.

• Repeating groups are eliminated (each entry a separated record).

Page 27: overview of database concept

First-Normal Form (1NF)

ISBN and Author columns together create a composite primary key

Page 28: overview of database concept

Composite Primary Key

• More than one column is required to uniquely identify a row

• When a primary key consists of more or one field, another problem may occurs--- partial dependency - a column/ns is/are only dependent on a portion of the primary keyThe fields describing the book depend of the book itself not upon who wrote.

Page 29: overview of database concept

Second-Normal Form (2NF)

• Partial dependency must be eliminated– Break the composite primary key into

two parts, each part representing a separate table (for example, Author)

Page 30: overview of database concept

Second-Normal Form (2NF)

BOOKS table in 2NF

Page 31: overview of database concept

Third-Normal Form (3NF)

Publisher contact name has been removed

Page 32: overview of database concept

Summary of Normalization Steps

• 1NF: eliminate repeating groups, identify primary key

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

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

Page 33: overview of database concept

Linking Tables

• Once tables are normalized, make certain tables are linked

• Tables are linked through a common field• A common field is usually a primary key in

one table and a foreign key in the other table

Page 34: overview of database concept
Page 35: overview of database concept

Graphical Representation for Books

Column Name ISBN Title Publication Date

Cost Retail Category PublId

Key Type PK FK1

Null/Unique

NN,U NN

FK RefTable

Publisher

FK Ref Columns PublId

Data type CHAR CHAR DATE NUMBER NUMBER CHAR NUMBER

Maximum Length

10 35 11 11 25 5

Sample Data 8843172113 DATABASE 11/AGO/2003 69.75 89.75 computers 1234

Page 36: overview of database concept

Lab # 1

• Find the graphical representations of tables considered in the Pet Shop.

Page 37: overview of database concept

Specialization

• Top-down design process; we designate subgroupings within an entity set that are distinctive from other entities in the set.

• These subgroupings become lower-level entity sets that have attributes or participate in relationships that do not apply to the higher-level entity set.

• Depicted by a triangle component labeled ISA (E.g. customer “is a” person).

• Attribute inheritance – a lower-level entity set inherits all the attributes and relationship participation of the higher-level entity set to which it is linked.

Page 38: overview of database concept

Generalization

• A bottom-up design process – combine a number of entity sets that share the same features into a higher-level entity set.

• Specialization and generalization are simple inversions of each other; they are represented in an E-R diagram in the same way.

• The terms specialization and generalization are used interchangeably.

Page 39: overview of database concept

UML

• UML: Unified Modeling Language• UML has many components to graphically

model different aspects of an entire software system

• UML Class Diagrams correspond to E-R Diagram, but several differences.

Page 40: overview of database concept

Structured Query Language (SQL)

• Data sublanguage • Used to:

– Create or modify tables– Add data to tables– Edit data in tables– Retrieve data from tables