each package gets a unique barcode number (ID) that is stored in a database. When it's scanned (at sort facility, at loading facility, out for delivery, at destination, etc.) then an entry is made into the database (or info is appended to a row) about the current status.
So when the user "tracks" their package, a query is called to the database to see what current information it has to give. Obviously, if the fields are blank, it won't show it.
Basically, the databases would look something like:
packages
ID_PCKG
sender
senddate
weight
size
type
destination
address
zipcode
state
service
est_delivery
signature
delivered
tracking
ID_TRACKER
ID_PCKG
facility
type
tracktime
So then each "scan" would insert into the tracking database something like:
1 | 1 | Null | Pickup Scheduled | 01/01/01 01:01
Hope you understand that 😉