Northcentral Technical College Introduction To Programming
10-152-310
Introduction to Programming with JavaScript NTC 10-152-310

Learning Plan 5 Processing Data Records

# Processing Data Records

#### File: /Learning Plan 5/processingDataRecords.html

### Records

> This is so common!

- In lots of programming tasks we need to be able to process records sequentially. The records can be in files, databases, entered live, or even from data on a distant server that was brought to your program with AJAX.
- A record is like a row in a spreadsheet. Here's an example of an employee record:

    1000, "John", "Smith", "Engineer", "555-1234"

- The `record` has discrete pieces of data that have been separated with commas. Each of the pieces of datum in the record is called a `field`.
- In data processing we sometimes call the commas a `delineator`.
- A `Record Set` (aka a `file`) is a bunch of records like the one above. The number of records in a record set can vary from just a few to many millions.
- Records can exist in many ways and you will learn lots of ways in your coming semesters. The most important way that organizations store data records these days are in databases. This is why there are several semesters of database courses in our programming degree.

### Record Processing

> One step at a time.

- JavaScript has an important security feature, it can't access your local hard drive in any way. This is to prevent malicious JavaScript code from doing damage to your computer. This is a really good thing when you are creating applications for real use, but it makes learning how to process records more difficult.
- Because JavaScript has no file Input/Output (I/O) capabilities we will be using a record processing system that has been custom-made to simulate record processing for the course. It allows us to learn to process records and data in a way that is similar to what you will be using in your future courses.
- In the `/Learning Plan 5/jsFiles/` directory there is a special JavaScript file that contains all the data and some code which allows us to use the data. Feel free to find it and look it over, but you won't need to edit the file in any way. It also might be a little difficult to understand at this point in your programming knowledge. You'll understand all of it before you are done with the degree.
- Here's how it works. When you are writing a program that needs to process records you will create a variable that stores all the records you need. For example, it might be named "records" as in the following example:

        var records;

- You then use a system function that starts with "open" to make the data available for use in your application. The particular one to use for any given record set will be documented in the lab or project file. After this function has been run your program will be ready to read the first record in the set.

        records = openSampleDataRecords();

- A function to read the next record. This makes the next record available if there are any more to be read. If there aren't anymore records then the function returns `false`. If there are more records then the function returns `true`. This is typically called as the loop conditional.

        records.readNextRecord();

- Let's see how this all works

### Available Record Sets

> Here is a list of the available records sets for this unit. Each one is a link to more details about the set.

- We'll be using these for labs, projects, and demos for this learning plan.
  - Student Exam Records
  - Student Enrollment Records
  - Inventory Items Records
  - Employee Payroll Records

### Record Processing Demo

- Here's a demo of how to loop through one of these record sets

### Here's a Lab to get started

- 5.1 Lab 5

### Here's another Lab to keep practicing

- 5.1 Lab 6