How Database works