Question: dpkg how does it work?
Answer: At a simple level, dpkg checks to see if dependencies/conflicts are met, extracts the files from the . deb file, runs any {pre,post}{inst,rm} scripts (whichever are applicable), and adds a record that the package is installed into its records (which is just a file, I think).