Successfully reported this slideshow.

Seasion7

1,254 views

Published on

Published in: Technology
  • Be the first to comment

Seasion7

  1. 1. DatabaseDatabase
  2. 2. Database Table • ก F (table) F ก F F •Table ก F row column • F table student ก F column (id) ก (name) ʾ• F table student ก F column (id) ก (name) ʾ (year) • ก F (column id) ˈ F F ก F row ก column F primary id name year projetcsoft.biz F F ก
  3. 3. Database Table •Table primary key F F F row ก array index 1,2,3, F F F F • F ก username password F (Table Admin)• F ก username password F (Table Admin) column F กF username password username ˈ primary key username F ก F F username password projetcsoft.biz F F ก
  4. 4. Database Table • (table subject) ก F 2 column F กF (id) (name) id name • F F ก F ก ก F F ก F F F (table score) F F F ก F ก (student_id), (subject_id) F(point) id name projetcsoft.biz F F ก
  5. 5. Database Table • F ก ˈ F F F F F student_id subject_id point • F ก ˈ F F F F F ก ก ก table student ก table subject • กก ก ก F F ก ˈ F F F ก F F F F ก primary key •primary key ก ก F foreign key projetcsoft.biz F F ก
  6. 6. Database Table projetcsoft.biz F F ก
  7. 7. Database Table projetcsoft.biz F F ก
  8. 8. Database Table projetcsoft.biz F F ก
  9. 9. ก F F ก F F F ก column ก F ก F Fก F ก ก F ก column department faculty ก F ก projetcsoft.biz F F ก
  10. 10. My SQL •My SQL ก ก database • ก F , , กF table , F , , กF column, F , , กF F row Fcolumn, F , , กF F row F • ก F ก ก database ก ก F F •Database Management System • ก F My SQL F ก F PHP MyAdmin projetcsoft.biz F F ก
  11. 11. PHP MyAdmin • App Serv F ก F PHP MyAdmin F ʽ ก web browser F F http://localhost F addresshttp://localhost F address projetcsoft.biz F F ก
  12. 12. PHP MyAdmin F ก phpMyAdmin Database Manager Version •Link ก •Web browser F F F login F F F root•Web browser F F F login F F F root username F password ก F Appserv projetcsoft.biz F F ก
  13. 13. Column Data Type • F MySQL F กF •INT •FLOAT•FLOAT •VARCHAR String ก F F F ก F F •TEXT String 65,535 ก •MEDIUMTEXT String 16,777,215 ก •DATE F YYYY-MM-DD •TIME F ˈ HH:MM:SS projetcsoft.biz F F ก
  14. 14. Autorun Primary key •ก F F F F ก ก F F array index ก F F ($array[1]) • F ก ก F F F primary key ˈ ก• F ก ก F F F primary key ˈ ก F F F F F • ก F column ˈ primary key F • F primary key auto run ˈ projetcsoft.biz F F ก
  15. 15. Database F ˈ case study projetcsoft.biz F F ก
  16. 16. SQL , , กF FSQL , , กF F SQL F ก Structure Query Langue , , กF , ก F F
  17. 17. SQL CREATE TABLE •CREATE TABLE ( • column F , •……………, •PRIMARY KEY ( column ˈ primary key )•PRIMARY KEY ( column ˈ primary key ) •) ENGINE = MYISAM DEFAULT CHARSET = utf8 •COLLATE = utf8_unicode_ci projetcsoft.biz F F ก
  18. 18. SQL CREATE TABLE •CREATE TABLE student( •id INT , •name VARCHAR(80 ) ,•name VARCHAR(80 ) , •PRIMARY KEY (id) •) ENGINE = MYISAM DEFAULT CHARSET = utf8 •COLLATE = utf8_unicode_ci projetcsoft.biz F F ก
  19. 19. SQL CREATE TABLE •CREATE TABLE subject( •id INT , •name VARCHAR(80 ) ,•name VARCHAR(80 ) , •PRIMARY KEY (id) •) ENGINE = MYISAM DEFAULT CHARSET = utf8 •COLLATE = utf8_unicode_ci projetcsoft.biz F F ก
  20. 20. CREATE TABLE score ( id int auto_increment, student_id int , subject_id int , public_date date , public_time time ,public_time time , point float , PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci F F ก F primary key ˈ auto increment F F auto_increment F projetcsoft.biz F F ก
  21. 21. SQL INSERT •INSERT INTO table_name(column_name,…) •VALUES (column_value,…) • F ก table subject• F ก table subject •INSERT INTO subject(id,name) •VALUES (112233 , “Basic Web Application”) • F ก ก F ก F column F ˈ ก F VARCHAR TEXT F F F F F “…” F ˈ F projetcsoft.biz F F ก
  22. 22. SQL INSERT • SQL F Student •INSERT INTO student(id,name) VALUES(47180187," ")VALUES(47180187," ") • SQL F score •INSERT INTO score(id, student_id, subject_id, point, public_date, public_time)VALUES •(null,47180187,112233,45.5,"2009-12- 31","23:59:10") projetcsoft.biz F F ก
  23. 23. SQL INSERT • F ก ก score •ก F column id ก F ˈ auto run primary key F ˈ null ( F F F F ˈ F F Fkey F ˈ null ( F F F F ˈ F F F column ˈ auto run MySQL F F F 1 F ก ก) •ก F column public_date ˈ F F F F “..” ˈ yyyy-mm-dd ( ʾ( . .)- - ) projetcsoft.biz F F ก
  24. 24. SQL INSERT •ก F column public_time ˈ F F F F “..” hh:mm:ss ( : : ) • F function NOW() SQL F ก ˆ FF •INSERT INTO score(id, student_id, subject_id, point, public_date, public_time)VALUES •(null,47180187,112233,45.5,NOW(),NOW()) projetcsoft.biz F F ก
  25. 25. SQL DELETE • F ก ก F •DELETE FROM WHERE primary key= • Fก F F F ก F F F ก ก F F array F F index ก F F F F ก F F primary key ก Fก F F F ก F F F ก ก F F F F index ก F F F F ก F F primary key ก F F F ก • ก F ก F F F F ก F primary key= ก F ก • F F F ก WHERE primary key= MySQL F ก projetcsoft.biz F F ก
  26. 26. SQL DELETE • id ˈ 9 score •DELETE FROM score WHERE id=9 • id ˈ 45180932 student• id ˈ 45180932 student •DELETE FROM student WHERE id=45180932 • id ˈ 1133675 subject •DELETE FROM subject WHERE id=1133675 • ก ก 2009-1-3 20:30:45 •DELETE FROM score WHERE (public_date="2009- 1-3") AND (public_time="20:30:45") projetcsoft.biz F F ก
  27. 27. SQL UPDATE • F ก ก ก F กก F ก ก F AND () FF •ก F ก F column public_date F ˈ "2009-1-3” column public_time F ˈ "20:30:45” F ก column public_date F ˈ "2009-1-3” Fcolumn public_time F F F ก ˈ "20:30:45” F ก F projetcsoft.biz F F ก
  28. 28. SQL UPDATE • ก กF F column F •UPDATE SET column= F F ก , column= F F ก WHERE primary key=column= F F ก WHERE primary key= • F ก DELETE F F F WHERE primary key= ˈ ก F F ก กF F • F กF F column ˈ primary projetcsoft.biz F F ก
  29. 29. SQL UPDATE • กF ก ก ˈ 5123454 •UPDATE student SET name=" กF " WHERE id=5123454WHERE id=5123454 projetcsoft.biz F F ก
  30. 30. SQL UPDATE • กF , ก ก 442331 321456 •UPDATE score SET public_date="2009-1-•UPDATE score SET public_date="2009-1- 3",public_time="20:30:45",point=12.8 WHERE (student_id=442331)AND(subject_id=321456) • ก F ก F ก ก INSERT projetcsoft.biz F F ก
  31. 31. SQL UPDATE • กF 987645 ก 47189187 •UPDATE score SET point=0 WHERE (student_id=47189187)AND(subject_id=987645)(student_id=47189187)AND(subject_id=987645) projetcsoft.biz F F ก
  32. 32. SQL SELECT •SELECT column_name, … FROM table_name • F column_name ก table_name • F SELECT id,name FROM subject ก ก F column id coulumn name subjectcolumn id coulumn name subject • F ˈ F ก column F F ก F column F F •SELECT name FROM student ก ก ก F student • ก F ก F ก column F F * •SELECT * FROM student projetcsoft.biz F F ก
  33. 33. SQL SELECT • F ก F (WHERE) F F ก UPDATE ก DELETE • WHERE ˈ logical operation ก• WHERE ˈ logical operation ก F F ก F F F ก ก F กก F F ก 20 112233 F •SELECT student_id FROM score WHERE (point>=20) AND(subject_id= 112233) projetcsoft.biz F F ก
  34. 34. SQL Logical Operation • SQL ก WHERE ˈ logical operation •(column_name operator value )AND|OR( •operator F F column ก F•operator F F column ก F F ก operator SQL F กF •= F ก <> F F ก > กก F >= กก F F ก •< F ก F <= F ก F F ก • value ก F column F F ˈ F F value F F F “..” projetcsoft.biz F F ก
  35. 35. SQL Logical Operation • F ก ก 47180187 •SELECT name FROM student WHERE •(id =47180187)•(id =47180187) projetcsoft.biz F F ก
  36. 36. SQL Logical Operation • F ก ก F F 20 30 112233 •SELECT student_id FROM score WHERE•SELECT student_id FROM score WHERE •(point >20)AND (point <30) •AND (subject_id =112233) projetcsoft.biz F F ก
  37. 37. ก F ก ก 11273 F sql F SELECT MAX(point) FROM score WHERE (subject_id =11273) SQL MAX MIN Function WHERE (subject_id =11273) ก ก F SELECT MIN(point) FROM score WHERE (subject_id =11273) projetcsoft.biz F F ก

×