SQL implementation. first commit.