Download Ch 11:Databases - Content - Faculty Personal Homepage

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Oracle Database wikipedia , lookup

Concurrency control wikipedia , lookup

Relational algebra wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Microsoft Access wikipedia , lookup

PL/SQL wikipedia , lookup

Database wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Ingres (database) wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Join (SQL) wikipedia , lookup

SQL wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Clusterpoint wikipedia , lookup

Versant Object Database wikipedia , lookup

Relational model wikipedia , lookup

Database model wikipedia , lookup

Transcript
3 / 12
Databases
MIS105
Irfan Ahmed Ilyas
More topics on Databases
• Databases Advantages
• Types of Databases
• Databases Uses and Issues
• Writing Queries in DBMS
11
Ch 11
© The McGraw-Hill Companies, Inc.
2000
CE 2
Databases Advantages
– Sharing information
• One department to another
– Security
• Password to access
– Less data redundancy
• Excess storage reduced
– Data integrity
• Consistent data
11
Ch 11
© The McGraw-Hill Companies, Inc.
2000
CE 3
Types of Databases
11
• Individual database
– Integrated files used by one person
• Shared database
– Common operational
– Common user
• Distributed database
• Proprietary database
• Web database
Ch 11
© The McGraw-Hill Companies, Inc.
2000
CE 4
Database Uses and Issues
11
• Strategic uses
– Data warehouse
– Data mining
• Many databases used everyday
– Business directories
– Business statistical information
– Web search databases
• Security issues
Ch 11
© The McGraw-Hill Companies, Inc.
2000
CE 5
Writing Queries in DBMS
1. What are Queries?
2. Available Query Types
•
•
Data Manipulation Queries
Data Definition Queries
3. Creating Queries in Access
1. QBE (Query By Example)
2. SQL (Structured Query Language)
11
Ch 11
© The McGraw-Hill Companies, Inc.
2000
CE 6
… Competencies
4. Working with SELECT Queries
1. Using Single Table
2. Multiple table
3. Parametric (Runtime Criteria) Query
11
Ch 11
© The McGraw-Hill Companies, Inc.
2000
CE 7
What Are Queries?
• Queries help the user to select information
from tables for a specific purpose
• Queries can
–
–
–
–
–
–
11
Ch 11
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
© The McGraw-Hill Companies, Inc.
2000
CE 8
Available Query Types
•
Data Manipulation Queries
•
SELECT Queries
–
•
UPDATE Queries
–
•
CREATE TABLE Queries
–
Ch 11
Delete some database records fulfilling some criteria
Data Definition Queries
•
11
Add more database records to some table
DELETE Queries
–
•
Modify database records (fulfilling some criteria)
APPEND Queries
–
•
Show database records fulfilling some criteria
Create new table\field types inside the database
© The McGraw-Hill Companies, Inc.
2000
CE 9
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
11
Ch 11
© The McGraw-Hill Companies, Inc.
2000
CE 10
An Example Query in a QBE
Grid
Query showing Saudi Faculty Members
11
Ch 11
© The McGraw-Hill Companies, Inc.
2000
CE 11
…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
11
Ch 11
© The McGraw-Hill Companies, Inc.
2000
CE 12
…Creating Queries in Access
• Example SQL Statements
SELECT Queries
SELECT <field name(s)>
FROM <table name(s)>
WHERE <condition(s)>;
– UPDATE Queries
UPDATE <table name(s)> SET <field name= value>
WHERE <condition(s)>;
11
Ch 11
© The McGraw-Hill Companies, Inc.
2000
CE 13
An Example Query in SQL View
Query showing Saudi Faculty Members in
SQL View
11
Ch 11
© The McGraw-Hill Companies, Inc.
2000
CE 14
Working with SELECT Queries
• SELECT Queries show
database records
fulfilling some criteria
• Query Criteria are
defined on one or more
field values
Logical Operators for building
Query Criteria
• Compound criteria
expressions can be
made (by using AND/
11 OR)
Ch 11
© The McGraw-Hill Companies, Inc.
Example Criteria
2000
Expressions CE 15
Working with SELECT Queries
Compound Criteria Queries (AND \ OR)
11
Ch 11
© The McGraw-Hill Companies, Inc.
2000
CE 16
1. SELECT Queries: Single Table
• Query only needs information from a single
table
• Example
– Faculty information is needed for Saudi Faculty
11
A SELECT Query with single table
Ch 11
© The McGraw-Hill Companies, Inc.
2000
CE 17
Query Result
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
11
Query Result
SELECT
Query with multiple
tables Companies, Inc.
Ch 11
© The McGraw-Hill
2000
CE 18
….SELECT Queries: Multiple Table
• Effect of using tables without any relationships
Jobs Table
Employee Table
11
Query Result: Cross
© The McGraw-Hill Companies, Inc. Product of Records
CE 19
Ch 11 Table Query having no relationship
Multiple
2000
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)
11
Query Result
Variable Value
Ch 11
© The McGraw-Hill Companies, Inc.
2000
CE 20
11
Ch 11
© The McGraw-Hill Companies, Inc.
2000
CE 21