Your "rap sheet" contains entries every time there is some sort of interaction with an agency that reports to the Department of Justice. If you are arrested and booked into jail, when you're fingerprinted, those records are input into the system by the police when you do the electronic fingerprinting. That will create an entry indicating the date of the arrest, the agency that arrested you and the charge. Ultimately, it is supposed to be updated with the resolution - that no case was filed and it is deemed a "detention only" or if there was a case filed in court. From there, if charges are filed, that will also show up, along with the case number, the court branch and the charge or charges filed against you.
There are other entries besides arrests and cases.
If you submit an application to a licensing agency or other organization that requires certification, etc. (such as to be a security guard, real estate agent, teacher, securities agent), an entry will be made indicating that you were an applicant.
How are they linked to you?
Criminal histories are linked by fingerprints, name, date of birth and social security number as well as an "index number" or CII number. If you are fingerprinted by live scan (those electronic prints), that incident is guaranteed to be linked to you. Some incidents, such as an arrest that does not involve being booked, may just link by name.
How to obtain your own copy of your criminal history
First, you'll need a copy of the Department of Justice's "Live Scan Form" found at the link below. Take that form to the Police Department, Sheriff's Department or other authorized Live Scan location (link to list of locations and fees found below). There will be a fingerprint fee (typically around $20, but I've seen them anywhere from $12 to $50) and a $25 processing fee to the Department of Justice. They will then mail you a copy of your background. They will also include information about what to do if you find inaccuracies on the report.