3 / 12 CHAPTER Databases MIS105 Irfan Ahmed Ilyas
11 CE 2 © The McGraw-Hill Companies, Inc Ch 11 More topics on Databases Databases Advantages Types of Databases Databases Uses and Issues Writing Queries in DBMS
11 CE 3 © The McGraw-Hill Companies, Inc Ch 11 Databases Advantages –Sharing information One department to another –Security Password to access –Less data redundancy Excess storage reduced –Data integrity Consistent data
11 CE 4 © The McGraw-Hill Companies, Inc Ch 11 Types of Databases Individual database –Integrated files used by one person Shared database –Common operational –Common user Distributed database Proprietary database Web database
11 CE 5 © The McGraw-Hill Companies, Inc Ch 11 Database Uses and Issues Strategic uses –Data warehouse –Data mining Many databases used everyday –Business directories –Business statistical information –Web search databases Security issues
11 CE 6 © The McGraw-Hill Companies, Inc Ch 11 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 CE 7 © The McGraw-Hill Companies, Inc Ch 11 … Competencies 4. Working with SELECT Queries 1.Using Single Table 2.Multiple table 3.Parametric (Runtime Criteria) Query
11 CE 8 © The McGraw-Hill Companies, Inc Ch 11 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
11 CE 9 © The McGraw-Hill Companies, Inc Ch 11 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
11 CE 10 © The McGraw-Hill Companies, Inc Ch 11 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 CE 11 © The McGraw-Hill Companies, Inc Ch 11 An Example Query in a QBE Grid Query showing Saudi Faculty Members
11 CE 12 © The McGraw-Hill Companies, Inc Ch 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 CE 13 © The McGraw-Hill Companies, Inc Ch 11 …Creating Queries in Access Example SQL Statements SELECT Queries –UPDATE Queries SELECT FROM WHERE ; UPDATE SET WHERE ;
11 CE 14 © The McGraw-Hill Companies, Inc Ch 11 An Example Query in SQL View Query showing Saudi Faculty Members in SQL View
11 CE 15 © The McGraw-Hill Companies, Inc Ch 11 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
11 CE 16 © The McGraw-Hill Companies, Inc Ch 11 Working with SELECT Queries Compound Criteria Queries (AND \ OR)
11 CE 17 © The McGraw-Hill Companies, Inc Ch 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
11 CE 18 © The McGraw-Hill Companies, Inc Ch 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
11 CE 19 © The McGraw-Hill Companies, Inc Ch 11 ….SELECT Queries: Multiple Table Effect of using tables without any relationships Employee Table Jobs Table Query Result: Cross Product of Records Multiple Table Query having no relationship
11 CE 20 © The McGraw-Hill Companies, Inc Ch 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 Result Variable Value
11 CE 21 © The McGraw-Hill Companies, Inc Ch 11