ELI5: Explain Like I'm 5

Referential integrity

Referential integrity means that things are connected properly. Just like how your toys fit together in a certain way and if they don’t fit, they feel funny, the information in a database needs to fit together properly.

Imagine you have a toy car and a toy garage that it fits in. If you don't put the toy car in the garage correctly or not all the way in, it won’t fit and you won’t be able to play with it properly. In a database, it’s the same way. If you have two tables that are related to each other and they aren’t connected correctly, you won’t be able to get the information you need.

For example, let’s say you have a table that lists all the toys in your room and another table that says which toys belong to which children in the house. If you forget to add a toy from one table to the other, then you might not be able to tell whose toy it is. Or, if you delete a child's record from one table, but not in the other, then you might have a toy that no longer belongs to anyone.

So when we talk about referential integrity, we're simply talking about making sure all of the pieces of information in a database fit together correctly, so that you can get the right information when you need it. That way, you’ll always know whose toys belong to whom and can play with them properly.