table schema and misc functions