Sorry, but I have some very basic questions that I would like to clarify:
Don't apologise, everyone has something to learn
The HEX codes on the US register are allocated to a registration and not to a particular aircraft. Therefore, when an aircraft changes registration, whether it stays in that country or not, its HEX code will change, is that correct?
Correct.
If so, is the HEX code deleted from the db, or does it stay in the db with an empty type field awaiting a new allocated aircraft?
AFAIK, aircraft removed from the US register are not automatically deleted from the database - in fact the DB shipped with RadarBox contains lots of examples of aircraft deregistered many years ago.
If an N-number is subsequently re-used, then I would expect the updaters to pick that up sooner or later, but with only about a third of available N-numbers in use at any one time there is no guarantee that a tail number will ever be re-used.
Do these rules apply to every country?
No. Although many countries do it that way, it's contrary to ICAO recommendations, which say that a hex code should only change when an aircraft is re-registered in another country.
The UK, of course, does it correctly - if an aircraft changes from one G- mark to another G- mark, it keeps its hex code.