completed build of SQL for notes functionality