Week11 final

33
Lecture 1 1 Introduction to Databases

Transcript of Week11 final

  1. 1. Lecture 11 Introduction to Databases
  2. 2. Todays lecture outline
  3. 3. Databases1
  4. 4. Where are databases used? 1) Maintaining address-books 2) Managing household budgets 3) Maintaining a home book-library a.
  5. 5. Where are databases used? b. 1) Inventory tracking system 2) Human resources/ payroll 3) Discipline specific databases
  6. 6. Where are databases used? c. 1) Police 2) Vehicle Registery 3) Banks 4) Tax records/ National IDs 5) All dynamic websites
  7. 7. Where are databases used? d. 1) Google 2) Amazon 3) Youtube 4) Websites having search facility
  8. 8. Databases Types2
  9. 9. Flat-file Databases2.a
  10. 10. Flat file tables Student Reg. No. ICT marks Student Reg. No. ECA marks Student Reg. No. Student Name Home City City Province Rural/ Urban
  11. 11. Student Reg. No. ICT marks 001 84 002 80 003 86 004 67 005 72 006 88 ICT instructors table A record, row or a tuple An attribute or a column
  12. 12. Student Reg. No. ECA marks 001 72 002 83 003 66 004 87 005 82 006 91 ECA instructors table
  13. 13. Student Reg. No. Students Name Home City 001 Ahmad Karachi 002 Mustafa Lahore 003 Hassan Sukhur 004 Qasim Peshawar 005 Tayyib Swat 006 Tahir Zhob Training Branchs table1 This column is shared between all tables till now
  14. 14. City Province Rural/ Urban Karachi Sindh Urban Lahore Punjab Urban Sukhur Sindh Rural Peshawar NWFP Urban Swat NWFP Rural Zhob Balochistan Rural Training Branchs table2 This column is shared with the table before
  15. 15. One flat file database Student Reg. No. ICT marks ECA marks Student Name Home City Home Province CityRural/ Urban
  16. 16. 16 Q. Whos the best student? Suppose, we are interested to find the highest scoring urban student. Problem: Searching a text file will not be efficient for large sizes of text file. Reason: One has to search sequentially through the entire file to gather desired info. How can performance be improved?
  17. 17. Relational Databases2.b
  18. 18. Relational databases Student Reg. No. ICT marks Student Reg. No. ECA marks Student Reg. No. Student Name Home City City Province Rural/ Urban
  19. 19. Student Reg. No. ICT marks ECA marks 001 84 72 002 80 83 004 67 87 New table generated Total marks 156 163 154 Its easy to find the highest-scoring rural student in the generated table
  20. 20. Relational Database Schema Student Reg. No. ICT marks Student Reg. No. ECA marks Student Reg. No. Student Name Home City City Province Rural/ Urban In a relational database, the schema defines: 1) the tables, 2) the fields in each table, and 3) the relationships between fields and tables.
  21. 21. Databases Management System3
  22. 22. What is a DBMS? A database management system is a software system that manages databases. : 1) Data Housekeeping (e.g., creating/ deleting/ backing up tables; data entry) 2) Data Sorting 3) Data Searching 4) Data Query Response and Report Generation
  23. 23. What is a DBMS? A DBMS ensures the following: 1) Data Integrity (correctness and consistency) Type Integrity (e.g., char input instead of numeric) Limit Integrity (e.g., age cannot be negative) Referential Integrity (e.g., referred item must exist) 2) Data Accessibility (support for concurrency) 3) Data Security (proper access control)
  24. 24. Data querying: SQL SQL is the standard database query language SQL is a 4G Computer language (non- procedural query specification language) : 1) Database schema creation/ modification 2) Retrieving/ manipulating database data
  25. 25. SQL example SELECT isbn, title, price, date FROM Book WHERE price > 100.00 AND (date = '2004-04-16' OR date = '2005-04-16') ORDER BY title; ISBN Title Author Edition InStock Price Date The database table: Book
  26. 26. Popular DBMS4
  27. 27. Example DBMS: MySQL
  28. 28. Data Mining5
  29. 29. What is Data Mining? Data mining is the process of (automatically) extracting useful information from data Also known as Knowledge Discovery in Databases (KDD) Data mining is used in: 1) Recommender systems 2) Pattern mining
  30. 30. Recommender Systems Youtube Amazon
  31. 31. Pattern Mining NZ team uses SAS data mining software for making team strategy
  32. 32. Todays lecture summary
  33. 33. http://tinyurl.com/5hb8pp