rewritten database handler to get edges from the database relation.
Added tests