Introduction to database

24,657 views

Published on

For a session in #Exceedcamp7

Published in: Technology
0 Comments
17 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
24,657
On SlideShare
0
From Embeds
0
Number of Embeds
146
Actions
Shares
0
Downloads
1,696
Comments
0
Likes
17
Embeds 0
No embeds

No notes for slide

Introduction to database

  1. 1. Introduction to Database<br />With Microsoft Office Access 2007<br />
  2. 2. Agenda<br />Getting to Know Database<br />Basic of Microsoft Office Access 2007<br />Basic Operations of Database<br />Structured Query Language (SQL)<br />CRUD Operations<br />
  3. 3. Getting to Know Database<br />
  4. 4. Definition of Database<br />Organized mechanism to store, manage and retrieve information<br />Efficient<br />Robust<br />Stable<br />Arranged in tabular fashion<br />Apparent relationship between information<br />The most important aspect<br />Won’t be taught in this class :-(<br />
  5. 5. Consists of a table, multiple fields and many columns<br />A Really Simple Database<br />
  6. 6. Organization of Database<br />Tables<br />Fields (Columns)<br />Has many types<br />Primary Key (Optional)<br />Records (Rows, Entries)<br />
  7. 7. When to Use Database? (1/3)<br />Appropriate<br />Appropriate<br />Inappropriate<br />Appropriate<br />Inappropriate<br />Appropriate<br />
  8. 8. When to Use Database? (2/3)<br />Transaction records<br />Logging<br />Blog/Forum<br />Media Library<br />Shopping list<br />Music playlist<br />Appropriate<br />Inappropriate<br />
  9. 9. When to Use Database? (3/3)<br />Managing mass amount of information<br />Sharing Information between many users<br />Manipulating complicatedly related information<br />Need security<br />Desire organization<br />
  10. 10. Under the Hood<br />Infrastructure of Database<br />Implementations in which we are going to learn<br />
  11. 11. Basic of Access 2007<br />
  12. 12. Don’t panic! You’ll soon be familiar with it.<br />Microsoft Office Access 2007<br />
  13. 13. Field Types (1/2)<br />
  14. 14. Field Types (2/2)<br />
  15. 15. Basic Operations of Database<br />
  16. 16. Structured Query Language (SQL)<br />Defines methods to manipulate database<br />Attempt to request something from Database is called Query<br />Each formed SQL statement refer as SQL Query<br />Resembles natural language<br />Has many standards<br />However, the basic part is still the same<br />
  17. 17. CRUD<br />Create new tables and records<br />Retrieve records from tables<br />Update tables’ definition and record’s data<br />Delete existing tables and records<br />
  18. 18. CRUD : Create<br />INSERT INTO <table_name> (<field_list>)<br />VALUES (<value_list>);<br />AutoNumber field must not be included<br />Examples<br />INSERT INTO students (nisit_id, name, surname) VALUES (51052744, “Pongsakorn”, “U-chupala”);<br />
  19. 19. CRUD : Create - Example<br />INSERT INTO students(nisit_id, name, surname)<br />VALUES (51052744, “Pongsakorn”, “U-chupala”);<br />
  20. 20. CRUD : Create - Example<br />INSERT INTO students(nisit_id, name, surname)<br />VALUES (51052744, “Pongsakorn”, “U-chupala”);<br />
  21. 21. CRUD : Create - Practice<br />Insert a record with every field specified<br />
  22. 22. CRUD : Retrieve<br />SELECT <select_list> FROM <table_name><br />[ WHERE <search_condition> ]<br />[ ORDER BY <order_expression> [ ASC | DESC ] ];<br />Select which fields to retrieve <br />Examples<br />SELECT field_1, field_2 FROM table_name …<br />SELECT * FROM table_name …<br />
  23. 23. CRUD : Retrieve<br />SELECT <select_list> FROM <table_name><br />[ WHERE <search_condition> ]<br />[ ORDER BY <order_expression> [ ASC | DESC ] ];<br />Available operators: =, <, >, <=, >=, <><br />Modifiers: AND, OR, NOT, ()<br />Examples<br />… WHERE student_id=1 …<br />… WHEHE (<cond1>) AND (<cond2>) …<br />
  24. 24. CRUD : Retrieve<br />SELECT <select_list> FROM <table_name><br />[ WHERE <search_condition> ]<br />[ ORDER BY <order_expression> [ ASC | DESC ] ];<br />Sort results by order expression ascending (default) or descending<br />Expression can be chained together<br />Examples<br />… ORDER BY date DESC …<br />… ORDER BY name ASC, surname ASC …<br />
  25. 25. CRUD : Retrieve - Example<br />SELECT name, height FROM students<br />WHERE height>160<br />ORDER BY height DESC;<br />
  26. 26. CRUD : Retrieve - Example<br />SELECT name, height FROM students<br />WHERE height>160<br />ORDER BY height DESC;<br />
  27. 27. CRUD : Retrieve - Practice<br />Select every record, sort by STU_ID, ascending<br />Select name, surname and height of everyone shorter than 170<br />Select everyone heavier than 70, sort by height, descending<br />
  28. 28. CRUD : Update<br />UPDATE <table_name> SET <field_value_list><br />[ WHERE <search_condition> ];<br />Update every record that match the search condition<br />We usually use primary key for this<br />Examples<br />UPDATE students SET name=“Knight”, surname=“Baron” WHERE nisit_id=1;<br />
  29. 29. CRUD : Update - Example<br />UPDATE students SET name=“Knight”, surname=“Baron”<br />WHERE nisit_id=51052744;<br />
  30. 30. CRUD : Update - Example<br />UPDATE students SET name=“Knight”, surname=“Baron”<br />WHERE nisit_id=51052744;<br />
  31. 31. CRUD : Update - Practice<br />Update the record that you’ve added earlier with different data<br />
  32. 32. CRUD : Delete<br />DELETE FROM <table_name><br />WHERE <search_condition> ;<br />Delete every record that match the search condition<br />Examples<br />DELETE FROM students WHERE id=1<br />DELETE FROM students WHERE (name=“Knight”) AND (surname=“Baron”);<br />
  33. 33. CRUD : Delete - Example<br />DELETE FROM students<br />WHERE (nisit_id=51052345) OR (nisit_id=51052744);<br />
  34. 34. CRUD : Delete - Example<br />DELETE FROM students<br />WHERE (nisit_id=51052345) OR (nisit_id=51052744);<br />
  35. 35. CRUD : Delete - Example<br />DELETE FROM students<br />WHERE (nisit_id=51052345) OR (nisit_id=51052744);<br />
  36. 36. CRUD : Delete - Practice<br />Delete the record you’ve modified earlier<br />
  37. 37. Conclusion<br />
  38. 38. Review<br />Getting to know Database<br />Definition<br />Organization<br />Practicing with Access 2007<br />Database operations<br />SQL Syntax<br />CRUD Operations<br />
  39. 39. Please do not hesitate to ask<br />Any Questions?<br />
  40. 40. Author: @KnightBaron<br />Blog: http://aosekai.net/<br />Email: knightbaron@gmail.com<br />Thank You!<br />
  41. 41. References<br />http://databases.about.com/od/specificproducts/a/whatisadatabase.htm<br />http://databases.about.com/od/sql/a/sqlfundamentals.htm<br />Old database slide from Exceed Camp #6<br />

×