Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 DATABASES – I IS 524 Dr. Chandra Amaravadi. 2 IN THIS PRESENTATION.. Importance of databases Real world concepts: entities, eclasses, attributes Data.

Similar presentations


Presentation on theme: "1 DATABASES – I IS 524 Dr. Chandra Amaravadi. 2 IN THIS PRESENTATION.. Importance of databases Real world concepts: entities, eclasses, attributes Data."— Presentation transcript:

1 1 DATABASES – I IS 524 Dr. Chandra Amaravadi

2 2 IN THIS PRESENTATION.. Importance of databases Real world concepts: entities, eclasses, attributes Data model Organization concepts DBMS & DBMS activities and functions

3 NEED FOR DATABASES A church needs to maintain information on donations A church needs to maintain information on donations A consulting company needs to manage its contacts A consulting company needs to manage its contacts A doctor needs to know if a patient is allergic to a particular medication. A doctor needs to know if a patient is allergic to a particular medication. An airline exec needs to know occupancy on a flight. An airline exec needs to know occupancy on a flight. Information is managed in a database. (Needs organization) All organizations need to manage information

4 4 BASIC DATA CONCEPTS

5 5 REAL WORLD CONCEPTS Entities Entities Entity Classes Entity Classes Attributes Attributes Data models Data models Database approach/philosophy Database approach/philosophy

6 6 ENTITIES Individual examples of things and objects are called entities. They are modelled only as a collection.

7 WE ARE MORE INTERESTED IN Organization Eclasses departments customers Sales/vendor product has has eclasses Organization deals with many eclasses

8 8 ENTITY CLASSES HAVE PROPERTIES Properties are called attributes Departments customers Sales/vendors machines/ parts Dept. code, name, manager, budget

9 9 DISCUSSION Classify the following as entity, entity class or attribute John (as a person) San Francisco (as name of a city) Customer Book Store# Customs Microsoft Microsoft employees The book “The Second Machine Age” Invoice Production

10 10 Entity – Individual example of person, place or thing. Entity Class – Collection of related entities. Attributes – Properties of entity classes about which we would like to collect information. SUMMARY OF CONCEPTS Eclasses & attributes are used in developing data models

11 11 Abstract view of the data & relationships Captures relationships between eclasses Supports DB design & implementation Relationship between students and courses? between doctors and patients? between teams and players? DATA MODELS (ER MODELS)

12 12 DATA MODELS… Three types of relationships among entity classes A B 1:1 A B 1:M A B M:N For each value of A, one and only one value of B and vice versa. For each value of A, many values of B, but for each B only one A. For each value of A, many values of B and vice versa.

13 13 DISCUSSION Identify the types of the following relationships Company -- president Instructor -- students Flights -- pilots City -- convention centers Club -- members Team – players (professional) Company -- city Books – authors Artists -- records

14 14 THE DATA BASE APPROACH Organization Entity classes Data model File 2 File 1 Data base cust. emp.

15 15 BASIC ORGANIZATION CONCEPTS

16 16 BASIC ORGANIZATION CONCEPTS data vs information data vs information attribute attribute primary key primary key file file record record schema schema

17 17 DEFINING DATA Data: Data consists of raw facts e.g. 298-2034 Are raw facts useful? meaningful? USA 46 29 29 104 China 38 27 23 88 Russia 24 26 32 82 Great Britain 29 17 19 65 Germany 11 019 14 44 Japan 7 14 17 38 Australia 7 16 12 34 France 11 11 12 34

18 18 INFORMATION Information: collection of facts, data presented in a context, elaboration of data. CountryGoldSilverBronzeTotal USA4629 104 China38272388 Russia24263282 Great Britain29171965 Germany11191444 Japan7141738 Australia7161235 France11 1234

19 19 INFORMATION AS A COLLECTION OF FACTS Collection of facts: Name: Chris Nash DOB: 2-4-1965 Profession: Engineer Address: 415 Walnut street. Details describe a person more. They are called ______

20 20 NOTION OF A RECORD Collection of facts is called a ________ Acct#: 4555950 Date: 12/5/14 Time: 4:48 pm Merchant: WIU Union Card type: Master Card Issuer: First Bank It is actually a collection of __________ values

21 21 ONE ATTRIBUTE HAS A UNIQUE VALUE Which of these has a unique value? Acct#: 4555950 Date: 12/5/14 Time: 4:48 pm Merchant: WIU Union Card type: Master Card Issuer: First Bank The unique attribute is called ___________. 330033053313

22 22 ORGANIZATION OF DATA/ INFORMATION Transaction#: 55643 Date: 12/5/14 Time: 4:08 pm Merchant: Vitales Card type: Master Card Issuer: First Bank Transaction#: 55644 Date: 12/6/14 Time: 4:10 pm Merchant: WIU Union Card type: Master Card Issuer: First Bank Observations about these two “units” of data?

23 23 TRADITIONAL CONCEPT OF A FILE Western Illinois University strives to maintain a community which values academic excellence; institutional integrity; and justice, equity, and diversity. Such an environment is essential in fostering the intellectual growth and personal development of all students. Each member of the University community shares responsibility in maintaining conditions which support the University's purpose. The Code of Student Conduct is designed to provide basic guidelines to advance the University's mission as a premier educational institution. A traditional file is a collection of characters Assume the following is stored somewhere,

24 24 Transaction ID Transaction Date Transaction Time Merchant 5564312/05/134:08 pmVitales 5564412/06/134:10 pmWIU Union CONCEPT OF A DATABASE FILE Transaction#: 55643 Date: 12/5/14 Time: 4:08 pm Merchant: Vitales Card type: Master Card Issuer: First Bank Transaction#: 55644 Date: 12/6/14 Time: 4:10 pm Merchant: WIU Union Card type: Master Card Issuer: First Bank A database file consists of _________________.

25 25 Primary key Record attr. values Attributes/field names Structure/schema DATABASE ORGANIZATION PROD#DESCR.PRICEQUANTITY IR888ERefrigerator$1,80020 TS3233Television$6732 Record A database is organized into ______, _________ and _______.

26 26 Database – A group of related files File/table – A group of related records Record – a grouping of related field values Attribute – property e.g. hair color Schema -- This is the logical view of the database (tables and fields) Primary key – An attribute whose values are unique within a file Secondary key – Any other attribute DBMS – software program to provide controlled data access Database Files/tables Records Attr. values DATABASE ORGANIZATION

27 27 DBMS

28 DBMS - SW program to create, manage and provide controlled access to the data Example Access, Oracle, DB2 What can we do with a DBMS? DBMS

29 29 DBMS ACTIVITIES & FUNCTIONS Define structure/schema Data entry Modify data query data get reports Activities with DBMS

30 30 Define structure/schema DATA DEFINITION Field NameData typeDescriptionLengthDecimals Prod#NumericUnique prod code 60 DescrTextShort prod description 250 PriceCurrencyProduct price62 Attributes and data types (and other characteristics) are specified as part of data definition

31 31 A form is used to enter data PRODUCT DATA ENTRY Product #: Description: Label Field Heading Data entry form DATA ENTRY

32 32 MODIFY DATA Add Delete Change Modify data Records/field values

33 33 Can use QBE or SQL to query data Query by example (QBE) form QUERYING DATA -QBE prod#descr.pricequantity < 200 list products costing less than $200 list employees in finance department e_ssnenameedepte_join_dt “finance”

34 34 RETRIEVAL WITH SQL The structured query language can be used instead of QBE Each SELECT statement has three parts SELECT, FROM and WHERE SELECT is used to select output attributes FROM is used to specify the source tables WHERE is used for row selection criteria e.g. price < 400; zip = 61455 etc. SELECT FROM WHERE

35 35 Flt#PnameConfirm# AA1802SmithPA5R2 PA802SmithLX5R2 UA3702MahoneyZB46A Select Flt#, Confirm# From Reservation Where Pname = “Smith”; Reservation RETRIEVAL WITH SQL.. SQL QUERY RESULT Flt# Confirm# AA1802 PA5R2 PA802 LX5R2

36 36 SELECT flt#, deptime, arrtime FROM ?? WHERE depcity = "PHX" and destcity = "ORD"; flt #depcitydestcitydeptimearrtime AA 802PHXORD1:51 AM6:05AM UA 3702COSD7:35 AM8:05 AM AA 812PHXSEA4:55 AM9:00 AM D 42PHXORD5:40 PM9:15PM UA775DFWSTL4:45 PM5:30 PM FLIGHTS ANOTHER EXAMPLE What is the result of the query?

37 37 DISCUSSION Write SQL queries to list: 1) employee names. 2) Employees who live in Macomb. 3) employees who enjoy soccer. EIDeNameeAddreCity 423Smith100 Oak laneMacomb 425Smith100 Oak laneMacomb 501Johnson1430 N. Park streetRock Island Emp

38 38 THE THEORY OF RETRIEVAL DEPTS. EMPLOYEES have EIDeNameeAddr. 11893Jon100 Oak street 11895Carey15 Candy lane 11896Ross1317 Fox creek dCodedName dMgr Fin.FinanceJon SasSales and serviceRoss Acc.AccountsJan Emp Dept list EID, eName, dName

39 39 SELECTtable1.attr1, table2.attr2.... FROMtable1, table2,..... WHERE table1.fkey = table2.fkey AND/OR condition1 AND/OR............. ; MULTI-TABLE SELECT STATEMENT When there are multiple tables, attr. names preceded by table name. “From” will have list of tables as usual. The WHERE part will have values of common attr. equated there can be more than one condition, connected by AND or OR RULES Used to retrieve data from more than one table Using the rules above, write a query to list EID, eName, dName

40 40 GETTING DATA OUT.. RH PH Detail Fields PF RF PRODUCT LISTING PRODUCT #DESCR.PRICE Product # Descr.Price Average Price Title Column Headings Footer A report specification

41 41 GETTING DATA OUT.. PRODUCT LISTING PROD# DESCRIPTION PRICE M100 Chair $ 50.00 M150 Table $200.00 Average Price $153.00 A generated report

42 42 SUMMARY OF DBMS ACTIVITIES Define structure /schema Enter data modify data query data get reports Activities with DBMS

43 43 D B M S Kernel Export/Import Data Defn. Data Defn. SQL Prog. Language Interface Prog. Language Interface Data Diction- ary Data Diction- ary Screen/ Report Gen. Screen/ Report Gen. Appln. Gen. Appln. Gen. DBMS ARCHITECTURE

44 44 USEFULNESS OF DATABASES

45 45 What if a customer wants know price of a shirt in a department store? Returns? What if a manager wants to know what products were sold on a particular day? Suppose we have detailed information on each and every transaction in a store, what can we do with that? USAGE OF DATA/INFORMATION

46 46 To store and record information e.g. bal, price, grades etc. To retrieve information e.g. check#432 cashed? To report information e.g. daily sales To answer queries e.g. how many shoes were sold? IMPORTANCE OF DBMS’s Operational Usage: To analyze trends Identify sales prospects Strategic Usage:

47 47 DISCUSSION QUESTIONS A collection of information about machines and parts is called _____? A collection of records is called________ ? The smallest unit of data in a database is _________ ? What is QBE apart from expansion of abbreviation? How does QBE differ from SQL? What does data definition mean? Where would databases be used? How are databases used? What is a good database application?

48 48 THAT’S ALL FOLKS!


Download ppt "1 DATABASES – I IS 524 Dr. Chandra Amaravadi. 2 IN THIS PRESENTATION.. Importance of databases Real world concepts: entities, eclasses, attributes Data."

Similar presentations


Ads by Google