M
M
Milliard2017-09-21 21:48:42
Database
Milliard, 2017-09-21 21:48:42

How is the database searched based on get url parameters?

Some services: Youtube, Yandex.Disk, other cloud storages, etc. add a parameter to the url that identifies a specific video or file, and consists of a set of letters and numbers. Something like 9bZkp7q19f0. Interested in how a database search is performed that matches these parameters with a file identifier (int32 or int64). It is logical that it makes no sense to sort through the entire database. I assumed that there is some kind of hash function that one-to-one translates this parameter into a number and vice versa, but I did not google anything. Are there such hash functions? And if not, how is the comparison made?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Tsvetkov, 2017-09-21
@Milliard

Something like 9bZkp7q19f0
This is the surrogate key. It can be calculated in any way (immediately unique or with verification). Counter (integer) is the simplest ID+1 function.
For example, musicbrainz.org/artist/d5c51c36-ac67-4727-91ed-ee9f0df81a2d is the UUID . In MS SQL, the NEWID() function returns a uniqueidentifier, the type used as the primary key.
For example, I sometimes use a function (instead of a counter) that fills in the gaps that occur when records are deleted.

X
xmoonlight, 2017-09-21
@xmoonlight

how a database lookup is performed that maps these options to a file id (int32 or int64)
This is the user post/post ID itself. No transformations with this parameter before extracting data from the database using it are done.
PS: this parameter is created at the time of creation (first save) of a post/record, key generation - can go through a stored procedure in the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question