SlideShare una empresa de Scribd logo
1 de 50
Database Basics
Good database design will get you through poor
programming better than good programming will get you
through poor database design….
Relational Database
• Definition:
– Data stored in tables that are associated by
shared attributes (keys).
– Any data element (or entity) can be found in the
database through the name of the table, the
attribute name, and the value of the primary
key.
Relational Database Definitions
• Entity: Object, Concept or event (subject)
• Attribute: a Characteristic of an entity
• Row or Record: the specific characteristics
of one entity
• Table: a collection of records
• Database: a collection of tables
The Relational Database model
•
•
•
•
•
•

Developed by E.F. Codd, C.J. Date (70s)
Table = Entity = Relation
Table row = tuple = instance
Table column = attribute
Table linkage by values
Entity-Relationship Model
The Relational Model
• Each attribute has a unique name within an
entity
• All entries in the column are examples of it
• Each row is unique
• Ordering of rows and columns is
unimportant
• Each position (tuple) is limited to a single
entry.
Data Model: What’s a model?
• A data model is a representation of reality
• It’s used to define the storage and
manipulation of a data base.
• Data Models have two components:
– Structure: the structure of the data stored within
– Operations: Facilities for manipulation of the
data.
Relational Database Systems
Most popular DBMS model for GIS
Flexible approach to linkages between records
comes the closest to modeling the
complexity of spatial relationships between
objects.
CRUD !
• Refers to the most common Database
Operations:
–
–
–
–

Create
Read
Update
Delete

• Operations occur at all levels: Tables,
Records, Columns
Database Tables
• Tables represent entities
• Tables are always named in the singular,
such as: Vehicle, Order, Grade, etc.
• Tables in database jargon are “flat files”,
dBase or Spreadsheet like..
Attributes
• Characteristics of an entity
• Examples:
– Vehicle (VIN, color, make, model, mileage)
– Student (SSN, Fname, Lname, Address)
– Fishing License (Type, Start_date, End_date)
Database Table Example

Figure 1: A simple – and flawed – table design.

Figure 2: An improved database table..
Database Views
• A View is an individual’s picture of a
database. It can be composed of many
tables, unbeknownst to the user.
– It’s a simplification of a complex data model
– It provides a measure of database security
– Views are useful, primarily for READ-only
users and are not always safe for CREATE,
UPDATE, and DELETE.
Table Indexing
• An Index is a means of expediting the
retrieval of data.
• Indexes are “built” on a column(s).
• Indexes occupy disk space; occasionally a
lot.
• Indexes aren’t technically necessary for
operation and must be maintained by the
database administrator.
B-Tree Index Example
• Commonly used with
“attribute” tables as well
as “graphic-attribute”
tables (CAD data
structures)
• Binary coding reduces the
search list by streaming
down the “tree”.
• A “balanced” tree is best.

Primary Key #
37
12
49
59
19
44
3

37

12
3

19

49
44

Number
Low

High

59
Database Relationships
• How is one entity related to another entity?
• Real-world sources:
–
–
–
–

Ownership
Parentage
Assignment
Regulation
Database Table Keys
Definition:
A key of a relation is a subset of attributes with the
following attributes:
• Unique identification
• Non-redundancy
Types of Keys
PRIMARY KEY
 Serves as the row level addressing mechanism in the relational
database model.
 It can be formed through the combination of several items.

FOREIGN KEY
 A column or set of columns within a table that are required to
match those of a primary key of a second table.

These keys are used to form a RELATIONAL JOIN thereby connecting row to row across the individual
tables.
Relational Database Management System
(RDBMS)
Table A
Name

Address

Parcel #

John Smith
T. Brown

18 Lawyers Dr.
14 Summers Tr.

756554
887419

Table B
Parcel #
887419
446397

Assessed Value
152,000
100,000
Database Keys
• Primary Key - Indicates uniqueness within
records or rows in a table.
• Foreign Key - the primary key from another
table, this is the only way join relationships
can be established.
• There may also be alternate or secondary
keys within a table.
Constructing Join Relationships
• One-to-many relationships include the
Primary Key of the ‘one’ table and a
Foreign Key (FK) in the ‘many’ table.
Other common terms
• Cardinality: one-to-one, one-to-many,
many-to-many relationships
• Optionality: the relationship is either
mandatory or optional.
Ensuring Database Integrity
• Database integrity involves the maintenance
of the logical and business rules of the
database.
• There are two kinds of “DB Integrity” that
must be addressed:
– Entity Integrity
– Referential Integrity
Strategies for managing Integrity
•
•
•
•

You could ignore it, but it costs you time.
Place the Burden on your customer or user.
Have the programmers “fix the problem”
Place the burden on the Database
Management System (DBMS)
• Temporal integrity is one of the key
challenges of Address Database
management.
Entity Integrity
• Entity integrity deals
with within-entity
rules.
• These rules deal with
ranges and the
permission of null
values in attributes or
possibly between
records
Examples of Entity Integrity
• Data Type Integrity: very common and
most basic. Checks only for “data type”
compatibility with DB Schema, such as:
numeric, character, logical, date format, etc.
• Commonly referred to in GIS manuals as:
– Range and List domains
• Ranges - acceptable Numeric ranges for input
• List - acceptable text entries or drop-down lists.
Enforcing Integrity
• Not a trivial task!
• Not all database management systems or
GIS software enable users to “enforce data
integrity” during attribute entry or edit
sessions.
• Therefore, the programmer or the Database
Administrator must enforce and/or check
for “Integrity.”
Referential Integrity
• Referential integrity concerns two or more
tables that are related.
• Example: IF table A contains a foreign key
that matches the primary key of table B
THEN values of this foreign key either
match the value of the primary key for a
row in table B or must be null.
Functions of a Database
Management System
•
•
•
•
•
•
•
•

Data Storage, Retrieval and Update (CRUD)
Catalog or Data Dictionary
Shared Update Support
Backup and Recovery Services
Security Services
Integrity Services
Data Independence - independent from programs
Various Data Manipulation Utilities
CRUD
• Four basic functions, for a given entity they
should all be performed with few
exceptions, in your system:
–
–
–
–

CREATE
READ
UPDATE
DELETE
Using SQL- Structured Query
Language
• SQL is a standard database protocol,
adopted by most ‘relational’ databases
• Provides syntax for data:
–
–
–
–

Definition
Retrieval
Functions (COUNT, SUM, MIN, MAX, etc)
Updates and Deletes
SQL Examples
• CREATE TABLE SALESREP
– Item definition expression(s)
• {item, type, (width)}

• DELETE table
– WHERE expression
Data Retrieval
• SELECT list FROM table WHERE
condition
• list - a list of items or * for all items
– WHERE - a logical expression limiting the
number of records selected
– can be combined with Boolean logic: AND,
OR, NOT
– ORDER may be used to format results
UPDATE tables
•
•
•
•

SET item = expression
WHERE expression
INSERT INTO table
VALUES …..
Database Normalization
• Normalization: The process of structuring data to
minimize duplication and inconsistencies.
• The process usually involves breaking down a
single Table into two or more tables and defining
relationships between those tables.
• Normalization is usually done in stages, with each
stage applying more rigorous rules to the types of
information which can be stored in a table.
Normalization
• Normalization: a process for analyzing the
design of a relational database
– Database Design - Arrangement of attributes
into entities

• It permits the identification of potential
problems in your database design
• Concepts related to Normalization:
– KEYS and FUNCTIONAL DEPENDENCE
Ex: Database Normalization (1)
• Sample Student
Activities DB Table
• Poorly Designed
– Non-unique records
• John Smith

• Test the Design by
developing sample
reports and queries
Ex: Database Normalization (2)
• Created a unique “ID”
for each Record in the
Activities Table
• Required the creation of
an “ID” look-up table
for reporting (Students
Table)
• Converted the “Flat-File
into a Relational
Database
Ex: Database Normalization (3)
• Wasted Space
• Redundant data entry
• What about taking a 3rd
Activity?
• Query Difficulties trying to find all
swimmers
• Data Inconsistencies conflicting prices
Ex: Database Normalization (4)
• Students table is fine
• Elimination of two
columns and an
Activities Table
restructuring,
Simplifies the Table
• BUT, we still have
Redundant data
(activity fees) and data
insertion anomalies.

Problem: If student #219
transfers we lose all references
to Golf and its price.
Ex: Database Normalization (5)
• Modify the Design to
ensure that “every
non-key field is
dependent on the
whole key”
• Creation of the
Participants Table,
corrects our problems
and forms a union
between 2 tables.

This is a Better Design!
Database Design: Basic Steps
• Step 1: Determine the entities involved and create
a separate table for each type of entity (thing,
concept, event, theme) and name it.
• Step 2: Determine the Primary Key for each table.
• Step 3: Determine the properties for each entity
(the non-key attributes).
• Step 4: Determine the relationships among the
entities
Design Example: Music CD
collection
• Entities: the CD, Tracks, Composer
• Attributes:
– CD (ID, title, musician, cost, etc.)
– Track (song title, length, order number)
– Composer (name, genre, DOB, DOD)

• Relationships: CD to Track, Composer to
Track
Table Design Example

Figure 1: A simple – and flawed – table design.

Figure 2: An improved database table..
Step1: Creating a Data Model
•
•
•
•

Identify Candidate Entities
Identify Relationships
Define Entities & Relationships
Review Entity-Relationship Model
Step 2: Defining an Attribute
Model
•
•
•
•
•

List Candidate Attributes for each Entity
Add KEYS to model
Attribute & Normalize Model
Define Attributes
Review Logical Model
Step 3: Identify & Capture
Business Rules
•
•
•
•

Review & Verify Cardinalities
Define Referential Integrity
Identify Business Domains
Identify Attribute Default Values
Step 4: Define Physical Model
•
•
•
•
•
•

Select Target DBMS
Name Tables & Columns
Name & Define Indexes
Define Columns
Verify/Update Triggers
Generate Reports & Document Design
Step 5: Review Final Design
•
•
•
•
•

Verify Entities & Definitions
Verify Relationships & Definitions
Verify Attributes & Definitions
Verify Business Constraints
Approve Schema Design
A Review of the Advantages of
Database Processing
• Lower cost… (relative it what?)
• More Information from same amount of
data
• Data Sharing is easier
• Controlled or elimination of redundancy
• Consistency, Integrity, Security
• Increased Productivity
Some Disadvantage of Database
Processing
•
•
•
•

Greater Complexity
Possibly a greater impact of a failure
Recovery is more difficult
Although these are all debated issues,
opportunities for complete failure are often
reduced with the latest database products,
but reliability results in higher investment
costs.

Más contenido relacionado

La actualidad más candente

Introduction to Database Concepts
Introduction to Database ConceptsIntroduction to Database Concepts
Introduction to Database ConceptsRosalyn Lemieux
 
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLESDATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLESNathRam2
 
Starting ms access 2010
Starting ms access 2010Starting ms access 2010
Starting ms access 2010Bryan Corpuz
 
L4 working with tables and data
L4 working with tables and dataL4 working with tables and data
L4 working with tables and dataBryan Corpuz
 
A short introduction to database systems.ppt
A short introduction to  database systems.pptA short introduction to  database systems.ppt
A short introduction to database systems.pptMuruly Krishan
 
Database management system
Database management systemDatabase management system
Database management systemedudivya
 
Week 1 Before the Advent of Database Systems & Fundamental Concepts
Week 1 Before the Advent of Database Systems & Fundamental ConceptsWeek 1 Before the Advent of Database Systems & Fundamental Concepts
Week 1 Before the Advent of Database Systems & Fundamental Conceptsoudesign
 
Relational database revised
Relational database revisedRelational database revised
Relational database revisedmnodalo
 
DATABASE PRESENTATION
DATABASE PRESENTATIONDATABASE PRESENTATION
DATABASE PRESENTATIONSunnyRajput34
 
Introduction to databases
Introduction to databasesIntroduction to databases
Introduction to databasesBryan Corpuz
 
computer fund-database presentation
 computer fund-database presentation computer fund-database presentation
computer fund-database presentationRakibul islam
 

La actualidad más candente (19)

RDMS AND SQL
RDMS AND SQLRDMS AND SQL
RDMS AND SQL
 
Introduction to Database Concepts
Introduction to Database ConceptsIntroduction to Database Concepts
Introduction to Database Concepts
 
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLESDATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
 
Starting ms access 2010
Starting ms access 2010Starting ms access 2010
Starting ms access 2010
 
L4 working with tables and data
L4 working with tables and dataL4 working with tables and data
L4 working with tables and data
 
Keerty rdbms sql
Keerty rdbms sqlKeerty rdbms sql
Keerty rdbms sql
 
A short introduction to database systems.ppt
A short introduction to  database systems.pptA short introduction to  database systems.ppt
A short introduction to database systems.ppt
 
Database management system
Database management systemDatabase management system
Database management system
 
Ch1- Introduction to dbms
Ch1- Introduction to dbmsCh1- Introduction to dbms
Ch1- Introduction to dbms
 
Week 1 Before the Advent of Database Systems & Fundamental Concepts
Week 1 Before the Advent of Database Systems & Fundamental ConceptsWeek 1 Before the Advent of Database Systems & Fundamental Concepts
Week 1 Before the Advent of Database Systems & Fundamental Concepts
 
Normalization
NormalizationNormalization
Normalization
 
Relational database revised
Relational database revisedRelational database revised
Relational database revised
 
RDBMS
RDBMSRDBMS
RDBMS
 
DATABASE PRESENTATION
DATABASE PRESENTATIONDATABASE PRESENTATION
DATABASE PRESENTATION
 
Introduction to databases
Introduction to databasesIntroduction to databases
Introduction to databases
 
computer fund-database presentation
 computer fund-database presentation computer fund-database presentation
computer fund-database presentation
 
Rdbms
RdbmsRdbms
Rdbms
 
Sql introduction
Sql introductionSql introduction
Sql introduction
 
DISE - Database Concepts
DISE - Database ConceptsDISE - Database Concepts
DISE - Database Concepts
 

Similar a Database intro

Week 2 - Database System Development Lifecycle-old.pptx
Week 2 - Database System Development Lifecycle-old.pptxWeek 2 - Database System Development Lifecycle-old.pptx
Week 2 - Database System Development Lifecycle-old.pptxNurulIzrin
 
Data resource management and DSS
Data resource management and DSSData resource management and DSS
Data resource management and DSSRajThakuri
 
Database Introduction by Luke Lonergan
Database Introduction by Luke LonerganDatabase Introduction by Luke Lonergan
Database Introduction by Luke LonerganLuke Lonergan
 
Ch 2-introduction to dbms
Ch 2-introduction to dbmsCh 2-introduction to dbms
Ch 2-introduction to dbmsRupali Rana
 
Data_base.pptx
Data_base.pptxData_base.pptx
Data_base.pptxMohit89650
 
7 - Enterprise IT in Action
7 - Enterprise IT in Action7 - Enterprise IT in Action
7 - Enterprise IT in ActionRaymond Gao
 
Sql server ___________session_1-intro
Sql server  ___________session_1-introSql server  ___________session_1-intro
Sql server ___________session_1-introEhtisham Ali
 
Unit I Database concepts - RDBMS & ORACLE
Unit I  Database concepts - RDBMS & ORACLEUnit I  Database concepts - RDBMS & ORACLE
Unit I Database concepts - RDBMS & ORACLEDrkhanchanaR
 
Lecture-8-The-GIS-Database-Part-1.ppt
Lecture-8-The-GIS-Database-Part-1.pptLecture-8-The-GIS-Database-Part-1.ppt
Lecture-8-The-GIS-Database-Part-1.pptPrabin Pandit
 
Info systems databases
Info systems databasesInfo systems databases
Info systems databasesMR Z
 

Similar a Database intro (20)

demo2.ppt
demo2.pptdemo2.ppt
demo2.ppt
 
Database_Introduction.pdf
Database_Introduction.pdfDatabase_Introduction.pdf
Database_Introduction.pdf
 
Week 2 - Database System Development Lifecycle-old.pptx
Week 2 - Database System Development Lifecycle-old.pptxWeek 2 - Database System Development Lifecycle-old.pptx
Week 2 - Database System Development Lifecycle-old.pptx
 
Database
DatabaseDatabase
Database
 
Topics-Ch4Ch5.ppt
Topics-Ch4Ch5.pptTopics-Ch4Ch5.ppt
Topics-Ch4Ch5.ppt
 
Topics-Ch4Ch5.ppt
Topics-Ch4Ch5.pptTopics-Ch4Ch5.ppt
Topics-Ch4Ch5.ppt
 
Data resource management and DSS
Data resource management and DSSData resource management and DSS
Data resource management and DSS
 
DB2 on Mainframe
DB2 on MainframeDB2 on Mainframe
DB2 on Mainframe
 
Database Introduction by Luke Lonergan
Database Introduction by Luke LonerganDatabase Introduction by Luke Lonergan
Database Introduction by Luke Lonergan
 
Ch 2-introduction to dbms
Ch 2-introduction to dbmsCh 2-introduction to dbms
Ch 2-introduction to dbms
 
database1.pdf
database1.pdfdatabase1.pdf
database1.pdf
 
Data_base.pptx
Data_base.pptxData_base.pptx
Data_base.pptx
 
7 - Enterprise IT in Action
7 - Enterprise IT in Action7 - Enterprise IT in Action
7 - Enterprise IT in Action
 
Sql server ___________session_1-intro
Sql server  ___________session_1-introSql server  ___________session_1-intro
Sql server ___________session_1-intro
 
MS ACCESS.pptx
MS ACCESS.pptxMS ACCESS.pptx
MS ACCESS.pptx
 
Unit I Database concepts - RDBMS & ORACLE
Unit I  Database concepts - RDBMS & ORACLEUnit I  Database concepts - RDBMS & ORACLE
Unit I Database concepts - RDBMS & ORACLE
 
Lecture-8-The-GIS-Database-Part-1.ppt
Lecture-8-The-GIS-Database-Part-1.pptLecture-8-The-GIS-Database-Part-1.ppt
Lecture-8-The-GIS-Database-Part-1.ppt
 
DBMS
DBMS DBMS
DBMS
 
MS-ACCESS.pptx
MS-ACCESS.pptxMS-ACCESS.pptx
MS-ACCESS.pptx
 
Info systems databases
Info systems databasesInfo systems databases
Info systems databases
 

Más de varsha nihanth lade (20)

154092688 rfp32sites
154092688 rfp32sites154092688 rfp32sites
154092688 rfp32sites
 
53373186 genpact-ppt
53373186 genpact-ppt53373186 genpact-ppt
53373186 genpact-ppt
 
34571759 apsrtc
34571759 apsrtc34571759 apsrtc
34571759 apsrtc
 
21516826 entrepreneurship-notes
21516826 entrepreneurship-notes21516826 entrepreneurship-notes
21516826 entrepreneurship-notes
 
11518224 marketing-strategy-of-itc-ltd
11518224 marketing-strategy-of-itc-ltd11518224 marketing-strategy-of-itc-ltd
11518224 marketing-strategy-of-itc-ltd
 
Bilal
BilalBilal
Bilal
 
All digree colleges adress
All digree colleges adressAll digree colleges adress
All digree colleges adress
 
Competitors
CompetitorsCompetitors
Competitors
 
Chapter4 120328061159-phpapp01
Chapter4 120328061159-phpapp01Chapter4 120328061159-phpapp01
Chapter4 120328061159-phpapp01
 
Chapter4 120328061159-phpapp01
Chapter4 120328061159-phpapp01Chapter4 120328061159-phpapp01
Chapter4 120328061159-phpapp01
 
Business news 19.08.2014
Business news 19.08.2014Business news 19.08.2014
Business news 19.08.2014
 
Entrepreneurial development
Entrepreneurial developmentEntrepreneurial development
Entrepreneurial development
 
Conotesmsn478141345715141 130221132620-phpapp01 (1)
Conotesmsn478141345715141 130221132620-phpapp01 (1)Conotesmsn478141345715141 130221132620-phpapp01 (1)
Conotesmsn478141345715141 130221132620-phpapp01 (1)
 
Businessquiz 131202075004-phpapp01
Businessquiz 131202075004-phpapp01Businessquiz 131202075004-phpapp01
Businessquiz 131202075004-phpapp01
 
Strategy web
Strategy webStrategy web
Strategy web
 
Rajani resume
Rajani resumeRajani resume
Rajani resume
 
Notesformbastrategicmanagementuniti 120924025055-phpapp02
Notesformbastrategicmanagementuniti 120924025055-phpapp02Notesformbastrategicmanagementuniti 120924025055-phpapp02
Notesformbastrategicmanagementuniti 120924025055-phpapp02
 
Cbproblems solutions
Cbproblems solutionsCbproblems solutions
Cbproblems solutions
 
Capital budgetingtraining
Capital budgetingtrainingCapital budgetingtraining
Capital budgetingtraining
 
Capital budgeting problems
Capital budgeting problemsCapital budgeting problems
Capital budgeting problems
 

Último

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Último (20)

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 

Database intro

  • 1. Database Basics Good database design will get you through poor programming better than good programming will get you through poor database design….
  • 2. Relational Database • Definition: – Data stored in tables that are associated by shared attributes (keys). – Any data element (or entity) can be found in the database through the name of the table, the attribute name, and the value of the primary key.
  • 3. Relational Database Definitions • Entity: Object, Concept or event (subject) • Attribute: a Characteristic of an entity • Row or Record: the specific characteristics of one entity • Table: a collection of records • Database: a collection of tables
  • 4. The Relational Database model • • • • • • Developed by E.F. Codd, C.J. Date (70s) Table = Entity = Relation Table row = tuple = instance Table column = attribute Table linkage by values Entity-Relationship Model
  • 5. The Relational Model • Each attribute has a unique name within an entity • All entries in the column are examples of it • Each row is unique • Ordering of rows and columns is unimportant • Each position (tuple) is limited to a single entry.
  • 6. Data Model: What’s a model? • A data model is a representation of reality • It’s used to define the storage and manipulation of a data base. • Data Models have two components: – Structure: the structure of the data stored within – Operations: Facilities for manipulation of the data.
  • 7. Relational Database Systems Most popular DBMS model for GIS Flexible approach to linkages between records comes the closest to modeling the complexity of spatial relationships between objects.
  • 8. CRUD ! • Refers to the most common Database Operations: – – – – Create Read Update Delete • Operations occur at all levels: Tables, Records, Columns
  • 9. Database Tables • Tables represent entities • Tables are always named in the singular, such as: Vehicle, Order, Grade, etc. • Tables in database jargon are “flat files”, dBase or Spreadsheet like..
  • 10. Attributes • Characteristics of an entity • Examples: – Vehicle (VIN, color, make, model, mileage) – Student (SSN, Fname, Lname, Address) – Fishing License (Type, Start_date, End_date)
  • 11. Database Table Example Figure 1: A simple – and flawed – table design. Figure 2: An improved database table..
  • 12. Database Views • A View is an individual’s picture of a database. It can be composed of many tables, unbeknownst to the user. – It’s a simplification of a complex data model – It provides a measure of database security – Views are useful, primarily for READ-only users and are not always safe for CREATE, UPDATE, and DELETE.
  • 13. Table Indexing • An Index is a means of expediting the retrieval of data. • Indexes are “built” on a column(s). • Indexes occupy disk space; occasionally a lot. • Indexes aren’t technically necessary for operation and must be maintained by the database administrator.
  • 14. B-Tree Index Example • Commonly used with “attribute” tables as well as “graphic-attribute” tables (CAD data structures) • Binary coding reduces the search list by streaming down the “tree”. • A “balanced” tree is best. Primary Key # 37 12 49 59 19 44 3 37 12 3 19 49 44 Number Low High 59
  • 15. Database Relationships • How is one entity related to another entity? • Real-world sources: – – – – Ownership Parentage Assignment Regulation
  • 16. Database Table Keys Definition: A key of a relation is a subset of attributes with the following attributes: • Unique identification • Non-redundancy
  • 17. Types of Keys PRIMARY KEY  Serves as the row level addressing mechanism in the relational database model.  It can be formed through the combination of several items. FOREIGN KEY  A column or set of columns within a table that are required to match those of a primary key of a second table. These keys are used to form a RELATIONAL JOIN thereby connecting row to row across the individual tables.
  • 18. Relational Database Management System (RDBMS) Table A Name Address Parcel # John Smith T. Brown 18 Lawyers Dr. 14 Summers Tr. 756554 887419 Table B Parcel # 887419 446397 Assessed Value 152,000 100,000
  • 19. Database Keys • Primary Key - Indicates uniqueness within records or rows in a table. • Foreign Key - the primary key from another table, this is the only way join relationships can be established. • There may also be alternate or secondary keys within a table.
  • 20. Constructing Join Relationships • One-to-many relationships include the Primary Key of the ‘one’ table and a Foreign Key (FK) in the ‘many’ table.
  • 21. Other common terms • Cardinality: one-to-one, one-to-many, many-to-many relationships • Optionality: the relationship is either mandatory or optional.
  • 22. Ensuring Database Integrity • Database integrity involves the maintenance of the logical and business rules of the database. • There are two kinds of “DB Integrity” that must be addressed: – Entity Integrity – Referential Integrity
  • 23. Strategies for managing Integrity • • • • You could ignore it, but it costs you time. Place the Burden on your customer or user. Have the programmers “fix the problem” Place the burden on the Database Management System (DBMS) • Temporal integrity is one of the key challenges of Address Database management.
  • 24. Entity Integrity • Entity integrity deals with within-entity rules. • These rules deal with ranges and the permission of null values in attributes or possibly between records
  • 25. Examples of Entity Integrity • Data Type Integrity: very common and most basic. Checks only for “data type” compatibility with DB Schema, such as: numeric, character, logical, date format, etc. • Commonly referred to in GIS manuals as: – Range and List domains • Ranges - acceptable Numeric ranges for input • List - acceptable text entries or drop-down lists.
  • 26. Enforcing Integrity • Not a trivial task! • Not all database management systems or GIS software enable users to “enforce data integrity” during attribute entry or edit sessions. • Therefore, the programmer or the Database Administrator must enforce and/or check for “Integrity.”
  • 27. Referential Integrity • Referential integrity concerns two or more tables that are related. • Example: IF table A contains a foreign key that matches the primary key of table B THEN values of this foreign key either match the value of the primary key for a row in table B or must be null.
  • 28. Functions of a Database Management System • • • • • • • • Data Storage, Retrieval and Update (CRUD) Catalog or Data Dictionary Shared Update Support Backup and Recovery Services Security Services Integrity Services Data Independence - independent from programs Various Data Manipulation Utilities
  • 29. CRUD • Four basic functions, for a given entity they should all be performed with few exceptions, in your system: – – – – CREATE READ UPDATE DELETE
  • 30. Using SQL- Structured Query Language • SQL is a standard database protocol, adopted by most ‘relational’ databases • Provides syntax for data: – – – – Definition Retrieval Functions (COUNT, SUM, MIN, MAX, etc) Updates and Deletes
  • 31. SQL Examples • CREATE TABLE SALESREP – Item definition expression(s) • {item, type, (width)} • DELETE table – WHERE expression
  • 32. Data Retrieval • SELECT list FROM table WHERE condition • list - a list of items or * for all items – WHERE - a logical expression limiting the number of records selected – can be combined with Boolean logic: AND, OR, NOT – ORDER may be used to format results
  • 33. UPDATE tables • • • • SET item = expression WHERE expression INSERT INTO table VALUES …..
  • 34. Database Normalization • Normalization: The process of structuring data to minimize duplication and inconsistencies. • The process usually involves breaking down a single Table into two or more tables and defining relationships between those tables. • Normalization is usually done in stages, with each stage applying more rigorous rules to the types of information which can be stored in a table.
  • 35. Normalization • Normalization: a process for analyzing the design of a relational database – Database Design - Arrangement of attributes into entities • It permits the identification of potential problems in your database design • Concepts related to Normalization: – KEYS and FUNCTIONAL DEPENDENCE
  • 36. Ex: Database Normalization (1) • Sample Student Activities DB Table • Poorly Designed – Non-unique records • John Smith • Test the Design by developing sample reports and queries
  • 37. Ex: Database Normalization (2) • Created a unique “ID” for each Record in the Activities Table • Required the creation of an “ID” look-up table for reporting (Students Table) • Converted the “Flat-File into a Relational Database
  • 38. Ex: Database Normalization (3) • Wasted Space • Redundant data entry • What about taking a 3rd Activity? • Query Difficulties trying to find all swimmers • Data Inconsistencies conflicting prices
  • 39. Ex: Database Normalization (4) • Students table is fine • Elimination of two columns and an Activities Table restructuring, Simplifies the Table • BUT, we still have Redundant data (activity fees) and data insertion anomalies. Problem: If student #219 transfers we lose all references to Golf and its price.
  • 40. Ex: Database Normalization (5) • Modify the Design to ensure that “every non-key field is dependent on the whole key” • Creation of the Participants Table, corrects our problems and forms a union between 2 tables. This is a Better Design!
  • 41. Database Design: Basic Steps • Step 1: Determine the entities involved and create a separate table for each type of entity (thing, concept, event, theme) and name it. • Step 2: Determine the Primary Key for each table. • Step 3: Determine the properties for each entity (the non-key attributes). • Step 4: Determine the relationships among the entities
  • 42. Design Example: Music CD collection • Entities: the CD, Tracks, Composer • Attributes: – CD (ID, title, musician, cost, etc.) – Track (song title, length, order number) – Composer (name, genre, DOB, DOD) • Relationships: CD to Track, Composer to Track
  • 43. Table Design Example Figure 1: A simple – and flawed – table design. Figure 2: An improved database table..
  • 44. Step1: Creating a Data Model • • • • Identify Candidate Entities Identify Relationships Define Entities & Relationships Review Entity-Relationship Model
  • 45. Step 2: Defining an Attribute Model • • • • • List Candidate Attributes for each Entity Add KEYS to model Attribute & Normalize Model Define Attributes Review Logical Model
  • 46. Step 3: Identify & Capture Business Rules • • • • Review & Verify Cardinalities Define Referential Integrity Identify Business Domains Identify Attribute Default Values
  • 47. Step 4: Define Physical Model • • • • • • Select Target DBMS Name Tables & Columns Name & Define Indexes Define Columns Verify/Update Triggers Generate Reports & Document Design
  • 48. Step 5: Review Final Design • • • • • Verify Entities & Definitions Verify Relationships & Definitions Verify Attributes & Definitions Verify Business Constraints Approve Schema Design
  • 49. A Review of the Advantages of Database Processing • Lower cost… (relative it what?) • More Information from same amount of data • Data Sharing is easier • Controlled or elimination of redundancy • Consistency, Integrity, Security • Increased Productivity
  • 50. Some Disadvantage of Database Processing • • • • Greater Complexity Possibly a greater impact of a failure Recovery is more difficult Although these are all debated issues, opportunities for complete failure are often reduced with the latest database products, but reliability results in higher investment costs.