Work-in-progress writing database module

Added numerous data types and functions. still in progress.