working database script