วันพฤหัสบดีที่ 18 ธันวาคม พ.ศ. 2557

ข้อสอบ O-NET


ข้อสอบ O-NET

1.ไฟล์ประเภทใดในข้อต่อไปนี้เก็บข้อมูลในลักษณะตัวอักษร
   1.  ไฟล์เพลง  MP 3 (mp 3)
   2.  ไฟล์รูปประเภท  JPEG (jpeg)
   3.  ไฟล์แสดงผลหน้าเว็บ (html)
   4.  ไฟล์วีดีโอประเภท  Movie (movie)
เฉลยข้อ  3
  
2.ในการออกแบบฐานข้อมูลดังกล่าวข้อใดกล่าวได้ถูกต้อง
   1.  ต้องสร้างตารางผู้ใช้ ตารางกระทู้และตารางคำตอบ
   2.  ไม่ต้องสร้างตารางผู้ใช้เนื่องจากสามารถบันทึกชื่อผู้ใช้ในตารางกระทู้และตารางคำตอบได้เลย
   3.  ต้องสร้างตารางผู้ใช้และตารางกระทู้ส่วนคำตอบจะอยู่ในตารางกระทู้อยู่แล้ว
   4.  ไม่ต้องสร้างตารางกระทู้เพราะสามารถบันทึกกระทู้ที่ผู้ใช้ตั้งในตารางผู้ใช้ได้เลย
เฉลยข้อ  4
  
3.ข้อใดเป็นการปฏิบัติที่ถูกต้องตามหลักวิชาการเมื่อค้นคว้าหาข้อมูลจากอินเทอร์เนตมาทำรายงาน
   1.  คัดลอกเนื้อหาจากเว็บไซต์
   2.  ใช้เนื้อหาจากกระดานสนทนา (Web board) มาใส่ในรายงาน
   3.  นำรูปภาพจากเว็บไซต์มาใส่ในรายงาน
   4.  อ้างอิงชื่อผู้เขียนบทความ
เฉลยข้อ  4

4.ผู้ประกอบอาชีพเป็นผู้พัฒนาเว็บไซต์ต้องเชี่ยวชาญความรู้ด้านใดบ้างจากตัวเลือกต่อไปนี้
   ก.  ฮาร์แวร์คอมพิวเตอร์        ข.  ระบบปฎิบัติการ
   ค.  เว็บเซิร์ฟเวอร์                   ง.  HTML
   จ.  ระบบฐานข้อมูล                ฉ.  ภาษาจาวา(Java) 
   1.  ข้อ  ก และ ค                    2.  ข้อ    และ   
   3.  ข้อ    และ                    4.  ข้อ    และ  
เฉลยข้อ  3

5.ข้อใดเป็นเทคโนโลยีการเชื่อมต่อข้อมูลไร้สายทั้งหมด
   1.  Wi-Fi  ,  IP              2.  Wi-Fi  ,Bluetooth
   3.  3G  ADSL                4.  3G    Ethernet
เฉลยข้อ  2

6.ข้อใดไม่ใช่ระบบปฏิบัติการที่นำมาใช้บนอุปกรณ์พกพาประเภท  Smartphone
   1.  Ubumtu       2.  Iphone  os
   3.  Android      4.  Symbian
เฉลยข้อ  1


7.ข้อใดไม่ใช่ข้อเสียของการละเมิดลิขสิทธิ์ซอฟต์แวร์
   1.  การทำผิดกฏหมายลิขสิทธิ์มีความผิดทางอาญา
   2.  เป็นช่องทางหนึ่งในการระบาดของไวรัสคอมพิวเตอร์
   3.  ผู้ใช้จะไม่ได้รับการบริการจากผู้พัมนาถ้าหากมีปัญหาการใช้งาน
   4.  ทำให้ผู้พัมนาซอฟแวร์ไม่มีรายได้เพื่อประกอบการและพัฒนาต่อไปได้
เฉลยข้อ  2

8.ห้องสมุดแห่งหนึ่งต้องการพัมนาระบบยืมหนังสือโดยสามารถบันทึกข้อมูลการยืมหนังสือลงบนบัตรอิเลคโทรนิกส์โดยไม่ต้องเขียนด้วยมือระบบนี้ควรใช้เทคโนโลยีในข้อใด
   1.  Smart  Card          2.  Fingerprint
   3.  Barcode                 4.  WiFi

เฉลยข้อ  3
  

9.ข้อใดต่อไปนี้ถูกต้องที่สุด
1.  การบันทึกข้อมูลลงแผ่นดีวีดีใช้เทคโนโลยีแบบแม่เหล็ก
2.  หมายเลขไอพีเป็นหมายเลขที่ใช้กำกับ  Network Interce Card
3.  หน่วยความจำสำรองเป็นหน่วยความจำที่มีคุณลักษณะแบบ Volntile
4.  รหัส ACIIและEBCIDICเป็นการวางรหัสตัวอักษรที่ใช้ขนาด  8 บิด
เฉลยข้อ  3 

10.ลิขสิทธิ์โปรแกรมประเภทรหัสเปิด (Open Source) อนุญาตให้ผู้ใช้ทำอะไรได้บ้าง
   ก.  นำโปรแกรมมาใช้งานโดยไม่ต้องเสียค่าลิขสิทธิ์
   ข.  ทดลองใช้โปรแกรมก่อนถ้าพอใจจึงจ่ายค่าลิขสิทธิ์
   ค.  แก้ไขปรับปรุงโปรแกรมเองได้ 
   1.  ข้อ  ก กับ  ข้อ        2.  ข้อ    กับ  ข้อ  
   3.  ข้อ    อย่างเดียว     4.  ข้อ    อย่างเดียว

เฉลยข้อ  4

คำสั่งSQL

คำสั่ง SQL

รู้จักกับภาษา SQL ? SQL หรือ Structured Query Language      เป็นภาษาที่ใช้ในการติดต่อกับฐานข้อมูลหรือพูดอีกอย่างก็คือ เป็นภาษาที่ใช้ในการสั่งให้ฐานฐานข้อมูลกระทำการใด ๆ ตามคำสั่งที่เราสั่ง ซึ่งในการติดต่อฐานข้อมูลนั้น ไม่ว่าจะเป็น SQL Server , Microsoft Access , MySQL ,DB2 หรือแม้แต่ Oracle ก็จะต้องใช้คำสั่งภาษา SQL ในการควบคุมทั้งสิ้น และเราจะมาเรียนรู้ถึงคำสั่งพื้นฐาน ของ SQL ที่จำเป็นกัน
     แต่ก่อนอื่นต้องทราบศัพท์ที่ใช้เรียกในตารางฐานข้อมูลก่อนนะครับสำหรับใครที่ยังไม่รู้จักคำว่า ฟิลด์(Field) และ เรกคอร์ด(Record) ผมไม่อธิบายมากนะเอาเป็นว่าดูตามรูปก็แล้วกัน
    โดยส่วนใหญ่แล้วการใช้คำสั่ง SQL เพื่อติดต่อฐานข้อมูลนั้น จะใช้โดยหลักคือ 3 กรณี
1. การเรียกดู
2. การแก้ไข ลบเพิ่มเปลี่ยนแปลง
3. การสร้างขึ้นใหม่

สำหรับตัวอย่างในบทเรียนนี้ ผมได้สร้าง Table ขึ้นมา 3 Table ครับ
1.customer เป็นตารางเก็บข้อมูลลูกค้า
2.audit เป็นตารางเก็บข้อมูลการใช้ยอดเงินลูกค้า
3.country เป็นตารางเก็บข้อมูลประเทศ

Table : Customer
CustomerID
Name
Email
CountryCode
Budget
Used
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
C002
John Smith
john.smith@thaicreate.com
EN
2000000
800000
C003
Jame Born
jame.born@thaicreate.com
US
3000000
600000
C004
Chalee Angel
chalee.angel@thaicreate.com
US
4000000
100000

Table : audit
AuditID
CustomerID
Date
Used
1
C001
2008-07-01
100000
2
C001
2008-07-05
200000
3
C001
2008-07-10
300000
4
C002
2008-07-02
400000
5
C002
2008-07-07
100000
6
C002
2008-07-15
300000
7
C003
2008-07-20
400000
8
C003
2008-07-25
200000
9
C004
2008-07-04
100000

Table : country
CountryCode
CountryName
TH
Thailand
EN
English
US
United states


  ** ที่มา http://www.thaicreate.com/tutorial/sql-database-introduction.html


SQL COUNT 
      เป็นคำสั่งที่ใช้สำหรับการระบุเงื่อนไขการเลือกข้อมูลในตาราง (Tableโดยทำการนับจำนวน Count Record       ที่ค้นพบ 
Database : MySQL,Microsoft Access,SQL Server,Oracle
Syntax 
 
SELECT COUNT(Column/Field) AS [New-Field] FROM [Table-Name]

Table : customer
CustomerID
Name
Email
CountryCode
Budget
Used
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
C002
John Smith
john.smith@thaicreate.com
EN
2000000
800000
C003
Jame Born
jame.born@thaicreate.com
US
3000000
600000
C004
Chalee Angel
chalee.angel@thaicreate.com
US
4000000
100000

Sample1 การเลือกข้อมูลจำนวนลูกค้าทั้งหมด
SELECT COUNT(CustomerID) AS CountCustomerID FROM customer

Output
CountCustomerID
4
  
 ** ที่มา http://www.thaicreate.com/tutorial/sql-count.html




SQL CREATE TABLE
    เป็นคำสั่งที่ใช้สำหรับการสร้างตารางใหม่ (Create New Tableในฐานข้อมูล
Database : MySQL,Microsoft Access,SQL Server,Oracle
Syntax
CREATE TABLE "TableName" 
(
ColumnName1 DataType ,
ColumnName2 DataType ,
...
)

Sample1 ทำการสร้างตาราง customer ประก้อบด้วยฟิวด์ฟิวด์CustomerID,Name,Email,CountryCode,Budget,Used
CREATE TABLE customer (
CustomerID varchar(4) NOT NULL,
Name varchar(50) NOT NULL,
Email varchar(50) NOT NULL,
CountryCode varchar(2) NOT NULL,
Budget double NOT NULL,
Used double NOT NULL
)

Output
CustomerID
Name
Email
CountryCode
Budget
Used


 ** ที่มา http://www.thaicreate.com/tutorial/sql-create-table.html


SQL MIN 
   เป็นคำสั่งที่ใช้สำหรับการระบุเงื่อนไขการเลือกข้อมูลในตาราง (Tableโดยหาค่าต่ำสุดในฟิวด์
Database : MySQL,Microsoft Access,SQL Server,Oracle
Syntax
SELECT MIN(Column/Field) AS [New-Field] FROM [Table-Name]

Table : customer
CustomerID
Name
Email
CountryCode
Budget
Used
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
C002
John Smith
john.smith@thaicreate.com
EN
2000000
800000
C003
Jame Born
jame.born@thaicreate.com
US
3000000
600000
C004
Chalee Angel
chalee.angel@thaicreate.com
US
4000000
100000

Sample1 การเลือกข้อมูล Budget ต่ำที่สุด
SELECT MIN(Budget) AS MinBudget FROM customer

Output
MinBudget
1000000

** ที่มา http://www.thaicreate.com/tutorial/sql-min.html




SQL MAX 
    เป็นคำสั่งที่ใช้สำหรับการระบุเงื่อนไขการเลือกข้อมูลในตาราง (Tableโดยหาค่าสูงสุดในฟิวด์
Database : MySQL,Microsoft Access,SQL Server,Oracle
Syntax
SELECT MAX(Column/Field) AS [New-Field] FROM [Table-Name]

Table : customer
CustomerID
Name
Email
CountryCode
Budget
Used
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
C002
John Smith
john.smith@thaicreate.com
EN
2000000
800000
C003
Jame Born
jame.born@thaicreate.com
US
3000000
600000
C004
Chalee Angel
chalee.angel@thaicreate.com
US
4000000
100000

Sample1 การเลือกข้อมูล Budget สูงที่สุด
SELECT MAX(Budget) AS MaxBudget FROM customer

Output
MaxBudget
4000000



 ** ที่มา http://www.thaicreate.com/tutorial/sql-max.html



SQL DISTINCT
    เป็นคำสั่งที่ใช้สำหรับการระบุเงื่อนไขการเลือกข้อมูลในตาราง (Tableโดยทำการเลือกข้อมูลที่ซ้ำกันมาเพียงแค่Record เดียว
Database : MySQL,Microsoft Access,SQL Server,Oracle
Syntax
SELECT DISTINCT Column1,Column2,Column3,... FROM [Table-Name]

Table : customer
CustomerID
Name
Email
CountryCode
Budget
Used
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
C002
John Smith
john.smith@thaicreate.com
EN
2000000
800000
C003
Jame Born
jame.born@thaicreate.com
US
3000000
600000
C004
Chalee Angel
chalee.angel@thaicreate.com
US
4000000
100000

Sample1 การเลือกข้อมูล CountryCode ที่ไม่ซ้ำกัน
SELECT DISTINCT CountryCode FROM customer

Output
CountryCode
TH
EN
US

** ที่มา http://www.thaicreate.com/tutorial/sql-distinct.html


SQL UNIQUE
    เป็นคำสั่งที่ใช้สำหรับการสร้าง UNIQUE ต้องการให้ฟิวด์หรือ Column นั้น ๆ มีค่าไม่ซ้ำกันของ Rows ทั้งหมด
Database : MySQL,Microsoft Access,SQL Server,Oracle
Syntax
CREATE TABLE "TableName" 
(
ColumnName1 DataType ,
ColumnName2 DataType ,
ColumnName3 DataType ,
ColumnName4 DataType ,
...
UNIQUE (ColumnName1,ColumnName2...)
)

หรือในกรณี ALTER

ALTER TABLE "TabmeName" ADD UNIQUE (Column1,Column2)

Table : customer
CustomerID
Name
Email
CountryCode
Budget
Used
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
C002
John Smith
john.smith@thaicreate.com
EN
2000000
800000
C003
Jame Born
jame.born@thaicreate.com
US
3000000
600000
C004
Chalee Angel
chalee.angel@thaicreate.com
US
4000000
100000

Sample 1 ต้องการทำ UNIQUE ของ Table customer สำหรับ Column ชื่อ Email (กรณีแก้ไข Table)
ALTER TABLE customer ADD UNIQUE (Email)

Output
CustomerID
Name
Email
CountryCode
Budget
Used
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
C002
John Smith
john.smith@thaicreate.com
EN
2000000
800000
C003
Jame Born
jame.smith@thaicreate.com
EN
3000000
600000
C004
Chalee Angel
chalee.angel@thaicreate.com
US
4000000
100000

เมื่อทำ UNIQUE แล้ว Column Email จะไม่สามารถมีค่าซ้ำกันของ Rows ทั้งหมด

** ที่มา  http://www.thaicreate.com/tutorial/sql-unique.html



SQL JOIN 
    เป็นคำสั่งที่ใช้สำหรับการระบุเงื่อนไขการเลือกข้อมูลในตาราง (Tableโดยเงื่อนไขการ JOIN จะกระทำเมื่อมีข้อมูลตั้งแต่ 2 Table ขึ้นไป โดยข้อมูลเหล่านั้นเป็นข้อมูลที่มีความสัมพันธ์และเชื่อมโยงกับข้อมูลหลัก
Database : MySQL,Microsoft Access,SQL Server,Oracle
Syntax
SELECT [Table-Name1].Column1, [Table-Name2].Column1,... FROM [Table-Name1],[Table-Name2]
WHERE [Table-Name1].Column = [Table-Name2].Column

Table : customer
CustomerID
Name
Email
CountryCode
Budget
Used
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
C002
John Smith
john.smith@thaicreate.com
EN
2000000
800000
C003
Jame Born
jame.born@thaicreate.com
US
3000000
600000
C004
Chalee Angel
chalee.angel@thaicreate.com
US
4000000
100000

Table : audit
AuditID
CustomerID
Date
Used
1
C001
2008-07-01
100000
2
C001
2008-07-05
200000
3
C001
2008-07-10
300000
4
C002
2008-07-02
400000
5
C002
2008-07-07
100000
6
C002
2008-07-15
300000
7
C003
2008-07-20
400000
8
C003
2008-07-25
200000
9
C004
2008-07-04
100000

Sample1 การเลือกข้อมูลแบบเชื่อมตาราง customer และ audit
SELECT customer.*,audit.* FROM customer,audit
WHERE customer.CustomerID = audit.CustomerID

Output
CustomerID
Name
Email
CountryCode
Budget
Used
AuditID
CustomerID
Date
Used
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
1
C001
2008-08-01
100000
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
2
C001
2008-08-05
200000
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
3
C001
2008-08-10
300000
C002
John Smith
john.smith@thaicreate.com
EN
2000000
800000
4
C002
2008-08-02
400000
C002
John Smith
john.smith@thaicreate.com
EN
2000000
800000
5
C002
2008-08-07
100000
C002
John Smith
john.smith@thaicreate.com
EN
2000000
800000
6
C002
2008-08-15
300000
C003
Jame Born
jame.smith@thaicreate.com
US
3000000
600000
7
C003
2008-08-20
400000
C003
Jame Born
jame.smith@thaicreate.com
US
3000000
600000
8
C003
2008-08-25
200000
C004
Chalee Angel
chalee.angel@thaicreate.com
US
4000000
100000
9
C004
2008-07-04
100000


Sample2 การเลือกข้อมูลแบบเชื่อมตาราง customer และ audit และ CustomerID = C001
SELECT customer.*,audit.* FROM customer,audit
WHERE customer.CustomerID = audit.CustomerID
AND customer.CustomerID = 'C001'

Output
CustomerID
Name
Email
CountryCode
Budget
Used
AuditID
CustomerID
Date
Used
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
1
C001
2008-08-01
100000
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
2
C001
2008-08-05
200000
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
3
C001
2008-08-10
300000

Sample3 การเลือกข้อมูลแบบเชื่อมตาราง customer และ audit และ CustomerID = C001 และแสดงผลเฉพาะตาราง audit
SELECT audit.* FROM customer,audit
WHERE customer.CustomerID = audit.CustomerID
AND customer.CustomerID = 'C001'

Output
AuditID
CustomerID
Date
Used
1
C001
2008-08-01
100000
2
C001
2008-08-05
200000
3
C001
2008-08-10
300000
  
 ** ที่มา http://www.thaicreate.com/tutorial/sql-join.html


SQL SUM 
    เป็นคำสั่งที่ใช้สำหรับการระบุเงื่อนไขการเลือกข้อมูลในตาราง (Tableโดยหาค่าผลรวมของฟิวด์
Database : MySQL,Microsoft Access,SQL Server,Oracle

Syntax
SELECT SUM(Column/Field) AS [New-Field] FROM [Table-Name]

Table : customer
CustomerID
Name
Email
CountryCode
Budget
Used
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
C002
John Smith
john.smith@thaicreate.com
EN
2000000
800000
C003
Jame Born
jame.born@thaicreate.com
US
3000000
600000
C004
Chalee Angel
chalee.angel@thaicreate.com
US
4000000
100000

Sample1 การเลือกข้อมูลผลรวมของ Budget
SELECT SUM(Budget) AS SumBudget FROM customer

Output
SumBudget
10000000

  ** ที่มา http://www.thaicreate.com/tutorial/sql-sum.html



SQL SELECT
    เป็นคำสั่งที่ใช้สำหรับการเรียกดูข้อมูลในตาราง (Tableคำสั่ง SQL SELECT สามารถเรียกได้ทั้งตาราง หรือว่า สามารถระบุฟิวด์ที่ต้องการเรียกดูข้อมูลได้
Database : MySQL,Microsoft Access,SQL Server,Oracle
Syntax
SELECT Column1, Column2, Column3,... FROM [Table-Name]

Table : customer
CustomerID
Name
Email
CountryCode
Budget
Used
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
C002
John Smith
john.smith@thaicreate.com
EN
2000000
800000
C003
Jame Born
jame.born@thaicreate.com
US
3000000
600000
C004
Chalee Angel
chalee.angel@thaicreate.com
US
4000000
100000

Sample1 การเลือกข้อมูลที่ระบุฟิวด์
SELECT CustomerID, Name, Email FROM customer

Output
CustomerID
Name
Email
C001
Win Weerachai
win.weerachai@thaicreate.com
C002
John Smith
john.smith@thaicreate.com
C003
Jame Born
jame.born@thaicreate.com
C004
Chalee Angel
chalee.angel@thaicreate.com

Sample2 การเลือกข้อมูลทั้งหมดของ Table
SELECT * FROM customer

Output
CustomerID
Name
Email
CountryCode
Budget
Used
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
C002
John Smith
john.smith@thaicreate.com
EN
2000000
800000
C003
Jame Born
jame.smith@thaicreate.com
US
3000000
600000
C004
Chalee Angel
chalee.angel@thaicreate.com
US
4000000
100000 

   ** ที่มา http://www.thaicreate.com/tutorial/sql-select.html




SQL RAND 
    เป็นคำสั่งที่ใช้สำหรับการระบุเงื่อนไขการเลือกข้อมูลในตาราง (Tableในรูปแบบของการสุ่ม Record
Database : MySQL
Syntax
SELECT Column1, Column2, Column3,... FROM [Table-Name] ORDER BY RAND() LIMIT [Int]

Table : customer
CustomerID
Name
Email
CountryCode
Budget
Used
C001
Win Weerachai
win.weerachai@thaicreate.com
TH
1000000
600000
C002
John Smith
john.smith@thaicreate.com
EN
2000000
800000
C003
Jame Born
jame.born@thaicreate.com
US
3000000
600000
C004
Chalee Angel
chalee.angel@thaicreate.com
US
4000000
100000

Sample1 การเลือกข้อมูลที่มีการใช้ยอดเงินมากที่สุดจำนวน 2 Record
SELECT * FROM customer ORDER BY RAND() LIMIT 2

Output
CustomerID
Name
Email
CountryCode
Budget
Used
C002
John Smith
john.smith@thaicreate.com
EN
2000000
800000
C003
Jame Born
jame.smith@thaicreate.com
US
3000000
600000

  ** ที่มา http://www.thaicreate.com/tutorial/sql-rand.html