3 / 12 CHAPTER Databases MIS105 Irfan Ahmed Ilyas.
-
date post
21-Dec-2015 -
Category
Documents
-
view
227 -
download
5
Transcript of 3 / 12 CHAPTER Databases MIS105 Irfan Ahmed Ilyas.
3 / 123 / 123 / 123 / 12CH
AP
TE
R
Databases
MIS105
Irfan Ahmed Ilyas
CE 2© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
More topics on Databases
• Databases Advantages
• Types of Databases
• Databases Uses and Issues
• Writing Queries in DBMS
CE 3© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
Databases Advantages
– Sharing information• One department to another
– Security• Password to access
– Less data redundancy• Excess storage reduced
– Data integrity• Consistent data
CE 4© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
Types of Databases
• Individual database– Integrated files used by one person
• Shared database– Common operational– Common user
• Distributed database• Proprietary database• Web database
CE 5© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
Database Uses and Issues
• Strategic uses
– Data warehouse
– Data mining
• Many databases used everyday
– Business directories
– Business statistical information
– Web search databases
• Security issues
CE 6© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
Writing Queries in DBMS
1. What are Queries?
2. Available Query Types• Data Manipulation Queries• Data Definition Queries
3. Creating Queries in Access1. QBE (Query By Example)2. SQL (Structured Query Language)
CE 7© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
… Competencies
4. Working with SELECT Queries1. Using Single Table
2. Multiple table
3. Parametric (Runtime Criteria) Query
CE 8© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
What Are Queries?
• Queries help the user to select information from tables for a specific purpose
• Queries can– Show the selected fields– Show selected records from one or multiple table– Update selected records– Delete selected records– Make new tables– Append records in an existing table
CE 9© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
Available Query Types
• Data Manipulation Queries• SELECT Queries
– Show database records fulfilling some criteria
• UPDATE Queries– Modify database records (fulfilling some criteria)
• APPEND Queries– Add more database records to some table
• DELETE Queries– Delete some database records fulfilling some criteria
• Data Definition Queries• CREATE TABLE Queries
– Create new table\field types inside the database
CE 10© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
Creating Queries in Access
• QBE (Query By Example) Approach– Allows a visual Query creation
– Query Grid allows to• select records from the required tables\
other queries• select only the desired field of the
records• sort the result on the basis of some field
values• specify record selection criteria
CE 11© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
An Example Query in a QBE Grid
Query showing Saudi Faculty Members
CE 12© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
…Creating Queries in Access
• Using SQL (Structured Query Language) Statements– A standard way of creating Queries – Applicable to all existing DBMS (relational)– A set of statements is used to create
Queries
In Access: View\ SQL View is used to write Queries directly in SQL
CE 13© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
…Creating Queries in Access
• Example SQL StatementsSELECT Queries
– UPDATE Queries
SELECT <field name(s)>
FROM <table name(s)>
WHERE <condition(s)>;
UPDATE <table name(s)> SET <field name= value>
WHERE <condition(s)>;
CE 14© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
An Example Query in SQL View
Query showing Saudi Faculty Members in SQL View
CE 15© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
Working with SELECT Queries• SELECT Queries show
database records fulfilling some criteria
• Query Criteria are defined on one or more field values
• Compound criteria expressions can be made (by using AND/ OR)
Logical Operators for building Query Criteria
Example Criteria Expressions
CE 16© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
Working with SELECT Queries
Compound Criteria Queries (AND \ OR)
CE 17© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
1. SELECT Queries: Single Table
• Query only needs information from a single table
• Example– Faculty information is needed for Saudi Faculty
Query Result
A SELECT Query with single table
CE 18© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
2. SELECT Queries: Multiple Table• Query needs information from more than one tables• All tables used must be properly related to each other
(using PK\ FK links)• Example
– Faculty information including their department name is needed
Query Result
SELECT Query with multiple tables
CE 19© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
….SELECT Queries: Multiple Table• Effect of using tables without any relationships
Employee TableJobs Table
Query Result: Cross Product of Records
Multiple Table Query having no relationship
CE 20© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111
3. SELECT Queries: Parametric
• When?– Criteria value is flexible to change during Query runtime
• Example– Faculty information who join the university in a given value
of Year (given during runtime)
Query ResultVariable Value
CE 21© The McGraw-Hill Companies, Inc. 2000
Ch 11
1111