File organisation and access
แนะนำใหม่
15:07
ประเภทข้อมูลที่กำหนดโดยผู้ใช้
ฟิลด์ข้อความธรรมดาจะเก็บข้อมูลไร้สาระได้อย่างสบายใจ ขอชนิดยานพาหนะมา คนหนึ่งพิมพ์ "กล้วย" — โปรแกรมรับไว้โดยไม่บ่น แต่หากคุณ…
บรรยายภาษาอังกฤษ · สลับคำบรรยายภาษาอังกฤษและภาษาจีนได้
ในบทเรียนนี้
| English | ความหมาย |
|---|---|
| magnetic tape | A storage medium that stores data on a long strip read in order. |
| transactions/trænˈsækʃnz/ | Actions that move money into or out of bank accounts. |
| master file | The main collection of records kept and updated over time. |
| file/faɪl/ | A collection of records stored at positions calculated from their keys. |
| Disks | Storage media that allow data to be read directly from known positions. |
| record/ˈrekɔːd/ | A stored collection of information about an item, person or event. |
| key/kiː/ | A value used to identify or look up an associated item, such as a key in a dictionary or database. |
| file organisation/faɪl ˌɔːɡənaɪˈzeɪʃn/ | การจัดระเบียบไฟล์ |
| serial file/ˈsɪərɪəl faɪl/ | ไฟล์ลำดับ |
| Appending | Adding new data or records to the end of a file. |
| searching/ˈsɜːtʃɪŋ/ | The process of looking through data to find a wanted item. |
| logs | Files that keep records of events or actions as they happen. |
| audit trails | Records of actions that allow changes and events to be checked later. |
| sequential file/siːˈkwenʃl faɪl/ | ไฟล์ตามลำดับ |
| sorted by a key field | Arranged in order according to the values in a chosen field. |
| binary-search | A search that repeatedly halves an ordered set of records to find a value. |
| batch/bætʃ/ | A group of tasks or records processed together at one time. |
| Direct access/daɪˈrekt ˈækses/ | Reading a record at a known position without reading earlier records. |
| record key | A value that uniquely identifies one record in a file. |
| hash/hæʃ/ | A function that calculates an initial storage address from a record key. |
| Lookup | The process of finding a record or value using a key. |
| lookup tables | Collections of stored values that can be found using keys. |
| access method/ˈækses ˈmeθəd/ | วิธีการเข้าถึง |
| Sequential access/siːˈkwenʃl ˈækses/ | Reading records in order from the start until the wanted record is reached. |
| random file/ˈrændəm faɪl/ | ไฟล์สุ่ม |
| indexed/ˈɪndekst/ | Describes data organised with a separate structure that helps the database find records faster. |
| scan/skæn/ | A search that reads records in order to find the wanted data. |
| collisions/kəˈlɪʒnz/ | A conflict such as different keys mapping to the same hash location, or simultaneous transmissions interfering on a shared network medium. |
| web server/web ˈsɜːvə/ | A computer or program that sends web content when users request it. |
| Hashing/ˈhæʃɪŋ/ | The process of calculating an initial record address from a key. |
| record address | The position in storage where a record is or can be placed. |
| algorithm/ˈælɡərɪθəm/ | A finite sequence of precise steps for solving a problem or carrying out a task. |
| overflow area/ˌəʊvəˈfləʊ ˈeərɪə/ | Extra storage used for records whose calculated file or hash-table locations are already occupied. |
| pointer/ˈpɔɪntə/ | A value that identifies a memory location or refers to another stored object. |
| chain/tʃeɪn/ | A series of connected records reached by following links between them. |
| key field/kiː fiːld/ | ฟิลด์คีย์ |
ทำไมงานกลางคืนของธนาคารจึงใช้เวลาทั้งคืน
- จนถึงยุค 1980 บัญชีของธนาคารอยู่บนเทปแม่เหล็ก. เทปอ่านได้เฉพาะจากปลายหนึ่งไปยังอีกฝ่ายหนึ่ง, ดังนั้นธุรกรรมประจำวันจึงถูกจัดอันดับกลางคืนและไฟล์หลักทั้งหมดถูกอ่านตั้งแต่ต้นจนจบ, ครั้งเดียว, เพื่อนำไปใช้
- ขอยอดเงินฝากของลูกค้าคนหนึ่งตรงกลางบ่ายคำตอบคือ: จนกว่าพรุ่งนี้. การจัดระเบียบไฟล์, ไม่ใช่ความเร็วของคอมพิวเตอร์, ตัดสินว่าธนาคารจะเสนออะไรได้
- ดิสก์ทำให้การจัดระเบียบแบบใหม่เป็นไปได้: คำนวณตำแหน่งของเรคอร์ดจากคีย์ของมันและกระโดดไปที่นั่น. นั่นคือสิ่งที่ทำให้ ATM ตอบกลับได้ในหนึ่งวินาที
- This lesson is file organisation, the two access methods, and how to choose from what the program mostly does.

สามการจัดระเบียบ
- ไฟล์แบบ serial เก็บเรคอร์ดตาม ลำดับที่ถูกเพิ่ม, โดยไม่มีการจัดอันดับ. การต่อท้าย (appending) รวดเร็ว;การค้นหาหมายถึงการอ่านตั้งแต่ต้น. ใช้สำหรับบันทึกและประวัติการตรวจสอบ
- ไฟล์แบบ sequential เก็บเรคอร์ด เรียงตามฟิลด์คีย์. การค้นหารวดเร็วขึ้น, เพราะคุณสามารถหยุดก่อนหรือ binary-search; การแทรกช้าลง, เพราะเรคอร์ดถัดไปต้องเลื่อน. ใช้สำหรับไฟล์หลักที่อัปเดตแบบ batch
- ไฟล์แบบ random, หรือ direct-access, ไฟล์ เก็บแต่ละเรคอร์ดที่ตำแหน่ง คำนวณจากคีย์เรคอร์ดของมัน, มักโดย hash. Lookup by key รวดเร็วมาก; อ่านตามลำดับคีย์ยาก. ใช้สำหรับตารางค้นหาขนาดใหญ่และบัญชีลูกค้า

Serial: ลำดับการมาถึง, ไม่มีอะไร więcej

Sequential: เรคอร์ดเดียวกัน, ตามลำดับคีย์
วิธีการเข้าถึงทั้งสอง
- Sequential access อ่านข้อมูลตั้งแต่ต้นไฟล์ไปจนถึงเรคอร์ดที่ต้องการ เป็นวิธีการเข้าถึงเดียวที่ serial file รองรับ และเป็นวิธีที่ sequential file ถูกประมวลผลในรูปแบบ batch
- Direct access ข้ามไปยังตำแหน่งที่ทราบไว้โดยตรงโดยไม่ต้องอ่านสิ่งที่มาก่อนหน้า เป็นวิธีการอ่านของ random file และ sequential file ก็สามารถอ่านแบบ direct ได้เมื่อทราบตำแหน่งของ key หรือมี index
- ดังนั้นการจับคู่ตามหลักสูตรคือ: sequential access สำหรับ serial และ sequential files; direct access สำหรับ sequential และ random files

Random: key บอกให้รู้ว่าต้องมองหาที่ไหน
File access route
Follow a file from storage to program and back safely.
A serial file stores records:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Serial files keep records in arrival order — fast to append, slow to search. Sequential files are sorted by key.
Match each file organisation to how it stores records.
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Serial = arrival order; sequential = sorted; random = hashed position; indexed-sequential = sorted + an index.
A random (direct-access) file places each record:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
A key is converted (often by a hash) to a position, so a single-key lookup is very fast.
What is the difference between a serial file and a sequential file?
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Order of arrival versus sorted by key. That single difference is what makes a sequential file searchable early and slow to insert into.
ตัวอย่างวิธีทำ: เลือกองค์กร
- A payroll program reads every employee record once a month, in employee-number order, to produce payslips. Which organisation and access, and why?
- Sequential organisation with sequential access: every record is processed, so there is nothing to gain from jumping about, and storing them in key order means the payslips come out in order with no sorting step.
- A cash machine must fetch one account by its number in under a second. Random organisation with direct access: the position is computed from the account number, so exactly one read is needed instead of a search through millions.
- แอปเซิร์ฟเวอร์เว็บเพิ่มบรรทัดหนึ่งต่อคำขอลงใน log Serial: การ add เข้าท้ายสำคัญที่สุด และการ add เข้าท้ายเป็นสิ่งที่เร็วที่สุดสำหรับ serial file

A sequential file can be read by sequential access and also by direct access.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Sequential access serves serial and sequential files; direct access serves sequential and random files. Only a serial file is limited to one method.
Put the steps of fetching one account from a random file in order.
ความยาก 3/5 · 200 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
The key is turned into an initial position and the record there is checked. If its key differs, follow the collision-resolution strategy to find the requested record.
ข้อแลกเปลี่ยน, เปรียบเคียงกัน
| serial | sequential | random | |
|---|---|---|---|
| ลำดับเรคอร์ด | ตามที่เพิ่มเข้ามา | เรียงตาม key | คำนวณจาก key |
| เพิ่มเรคอร์ด | เร็ว, add เข้าท้าย | ช้า, เรคอร์ดขยับตำแหน่ง | เร็ว, หากช่องว่างมีอยู่ |
| หาเรคอร์ดหนึ่ง | ช้า, อ่านทั้งหมด | รวดเร็วกว่า, สามารถหยุดก่อนได้ | รวดเร็วที่สุด, อ่านเพียงครั้งเดียว |
| อ่านตามลำดับ key | ต้องใช้ sort | เป็นธรรมชาติ | ต้องใช้ sort |
- คำตอบที่ถูกต้องต้องอธิบายจาก dominant operation: โปรแกรมนี้ทำอะไรมากที่สุด?

Sequential file organisation is well suited to processing every record in turn.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Direct access suits looking up a single record.
Match each situation to the file organisation that suits it.
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Append only, process everything in order, or look one record up: the dominant operation picks the organisation.
ตัวอย่างวิธีทำ: อธิบายเหตุผลของการเปลี่ยนแปลง
- ไฟล์หนังสือของห้องสมุดเป็น serial การค้นหาชื่อเรื่องหนึ่งช้า แนะนำการเปลี่ยนแปลงและอธิบายเหตุผล
- Reorganise as a random file, hashing the ISBN to an address, so a search becomes one direct read instead of a scan of the whole file.
- หากคลังหนังสือพิมพ์รายการชื่อตามลำดับตัวอักษรด้วย การจัดระเบียบแบบ เรียงลำดับ ตามชื่อจึงใช้ประโยชน์ได้ทั้งสองอย่าง: รายการไม่ต้องมีการเรียงลำดับ และการค้นหาสามารถหยุดก่อนหรือใช้การค้นหาคู่.binary-search
- ระบุชื่อการจัดระเบียบ ระบุชื่อวิธีการเข้าถึง และเชื่อมโยงทั้งสองเข้ากับกิจกรรมที่โจทย์กล่าวถึง
To produce reports in key order, the best file organisation is:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
A sequential file is already in key order, so reading it sequentially gives an in-order report.
A file organisation is chosen by looking at the program's ____ operation.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Every organisation is fast at something and slow at something else, so the operation done most often decides.
Key ต้องเป็นอย่างไร และทำไม hashing ถึงล้มเหลว
- Direct access ต้องการ key และ key ต้อง unique กับเรคอร์ดหนึ่งเท่านั้น LastName ไม่ใช่ key แต่customer number คือ
- Hashing แปลง key นั้นเป็นที่อยู่เรคอร์ดด้วยการคำนวณเพียงครั้งเดียว ดังนั้นการอ่านเพียงครั้งเดียวจะเข้าถึงเรคอร์ดไม่ว่าไฟล์จะมีขนาดใหญ่แค่ไหนก็ตาม
- Two different keys สามารถ hash ไปยัง address เดียวกัน นั่นคือ collision และไม่ใช่ข้อผิดพลาดของอัลกอริทึม: มันหลีกเลี่ยงไม่ได้เมื่อจำนวน key ที่เป็นไปได้มากกว่า address
- คำแก้ไขที่ระบุไว้ในเกณฑ์ให้คะแนนคือ พื้นที่ล้นออก หรือการจัดเก็บ พอยเตอร์ ที่ที่อยู่ไปยังลิงก์ของบันทึกที่แบ่งปันกัน ความขัดแย้งดังนั้นจึงมีค่าใช้จ่ายในการอ่านเพิ่มหนึ่งครั้ง ไม่ใช่การสูญเสียบันทึก
- ดังนั้นการเปรียบเทียบที่จริงใจคือ: hashing ให้การเข้าถึงที่เกือบคงที่ จนกว่าไฟล์จะเต็ม และประสิทธิภาพจะลดลงเมื่อ collision สะสมขึ้น Sequential access ไม่เคยเสื่อมสภาพแต่ไม่เคยรวดเร็ว

Two records hash to the same address. Which are true? Select ทั้งหมด that apply.
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
A collision need not lose a record, but resolving it can require additional reads. Collisions are unavoidable if there are more possible keys than addresses.
คะแนนที่หลุดหายไป
- Serial is order of arrival; sequential is sorted by a key. They are not synonyms, and the exam tests exactly that difference.
- การจัดระเบียบ คือวิธีที่บันทึกถูกวางเรียง; การเข้าถึง คือวิธีที่โปรแกรมเข้าถึงหนึ่งบันทึก โจทย์จะระบุอย่างใดอย่างหนึ่ง
- Sequential file รองรับ both methods of access; serial file รองรับเฉพาะ sequential access เท่านั้น
- อธิบายเหตุผลจาก dominant operation ไม่ใช่จาก "มันเร็วกว่า" บอกว่าเร็วกว่าอะไร และทำไม
การ์ดนี้ได้รับการแก้ไขแล้ว จึงแสดงเป็นภาษาอังกฤษจนกว่าคำแปลจะได้รับการอัปเดต
You've got it
- serial: order added, append fast, search slow, used for logs · sequential: sorted by a key field, good for batch processing and in-order output · random: initial position computed from the record key, with extra reads possible after collisions
- sequential access 顺序存取 reads from the start; direct access jumps to a position
- sequential access serves serial and sequential files; direct access serves sequential and random files
- choose from the dominant operation: process everything, look one up, or only append
เกิดปัญหาอะไรขึ้น? เฉพาะทีมเว็บไซต์เท่านั้นที่เห็นข้อมูลนี้