There's a lot to say about VSAM. I've seen multi-part presentations on the topic of VSAM. There are courses on VSAM alone that run four to five days. We've got a couple minutes, so let's get going. We'll start with the basics. VSAM stands for virtual storage access method. It's a way of storing and accessing data that's different from what we've been using up until now. So why do we need another type of data set? The ones we were looking at before made perfect sense. I open it up, I put my data in, I close it, the data's still there next week. All's good, right? Well, for you and I, sure. But what about the applications? Applications generally aren't reading blogs, and writing novels, scrolling social media. They've got a specific piece of data that they've got to get to present to their user. Or they've got to make an update on a very specific piece of data in a very specific place. VSAM gives applications a method of reading and writing data that makes sense for them. In fact, if you were to try and open up a VSAM data set in ispf, all it would do is tell you yep, that's a VSAM data set, because it's not readable by standard methods. So how does this work? Well, like the other datasets we've talked about, VSAM has records. In VSAM, those records are kept in what's called a control interval. And a control interval is a continuous area of storage on DASD, and they can be different sizes. So when an application goes to read a control interval, that specific area of storage gets read into the VSAM I/O buffer so the application can read it. VSAM has four types of data sets based around four different ways that applications generally like to consume and record data. They are keyed sequence data sets, entry sequence data sets, relative record data sets, and linear data sets. Okay, one at a time. Keyed sequence data sets, or KSDS. In a KSDS, each record is identified by a unique key. When you write new data, you create a key for it. For example, if this were an automobile assembly line, the index might be a unique vehicle identification number, and the data portion holds what features that car's being built with, what color it is, which dealership it's going to, all that stuff. Whenever we want that specific piece of information, we look it up by the key. This is the most commonly used type of VSAM data set. And then, there's entry sequence data sets. In an ESDS, each new entry goes in right after the last one, and records are referenced by the relative byte address. So if we know the records are 64 bytes each, and we want to reference the first record, the RBA is 0. And for the second it's 64. And for the third one, it's 128 and so on. Because the records go in one right after the other, and that's their structure, you can't delete a record once it's in there, you can only mark it as inactive. This structure generally lends itself to high performance when data is loaded and read sequentially. Now, an RRDS, or relative record data set, is similar to an ESDS except that the records are referenced by the relative record number, or RRN. This number is how many records down from the first record we are, similar to rows in a spreadsheet. And like a spreadsheet, we can have empty records, we can delete records, we can jump around, or we can go sequentially. Lastly, there's linear data sets. These aren't used as often but are still helpful when dealing with byte stream data like logs or where an application will be managing the data after it grabs it. Let's test your understanding of these VSAM data set types with a little pop quiz. Let's say I need a VSAM data set to record data in sequence, and I just happen to know that the program that processes this data is going to read it in sequence without skipping around. What type of data set should I be looking into? The answer is an ESDS, or entry sequence data set. Because members go in based on when they're recorded and we have no need to reference individual records by name or relative number, we can make efficient use of an ESDS here. No matter what data set type you're using, they usually get created using an IBM utility called IDCAMS through JCL. In your JCL, you'll specify the cluster, that's the logical representation of that data set, and all that goes along with it. So in this example here, you can see we're invoking the IDCAMS program and creating a cluster with the name EXAMPLE.KSDS2. If I were a betting man, I'd say this is a key sequence data set. And not just because of the name, but because down here, we're specifying the key length. Here, it's six bytes, starting at the fifth byte, byte 4 since we start from 0 of the data record. We need to provide the information for the cluster itself, as well as the data and index of the cluster. In this example, we're also specifying which catalog we want to keep the cluster in. You can also use JCL itself to create VSAM data sets, in which case you specify the record organization, RECORG parameter. The fundamentals, however, stay the same. So that's a little bit about VSAM. I gotta tell you, this is one of those things that everybody uses. It's very prevalent in the Mainframe Community. It's also one of those things that's fairly unique to the Z platform. And there's a lot of performance and code simplification to be gained by using it. So when you're done with this course and you're trying to take the next step, make sure you read further into it. You can never have too much VSAM knowledge.