The logic for saving and finding photos is the interaction between the Instagram server and database.
SQL is one tool used to code this logic.