<?xml version="1.0"?>
<!DOCTYPE database SYSTEM "http://jakarta.apache.org/turbine/dtd/database.dtd">

<database name="Roster"
	defaultIdMethod="idbroker"
	defaultJavaType="object"
	defaultJavaNamingMethod="javaname"
	package="org.thdl.roster.om">

<!--roster-members-->
<table name="Member">
	<!--meta-->
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="created_by" required="true" type="INTEGER"/>
	<column name="modified_by" required="true" type="INTEGER"/>
	<column name="created_on" required="true" type="TIMESTAMP"/>
	<column name="modified_on" required="true" type="TIMESTAMP"/>
	<column name="deleted" required="true" size="5" type="CHAR"/>
	<!--children-->
	<column name="contact_info_id" type="INTEGER"/>
	<column name="research_interest_id" type="INTEGER"/>
	<column name="publication_id" type="INTEGER"/>
	<!--inheritance key DO NOT CHANGE COLUMN NAME!!!-->
	<column name="member_type" inheritance="single" required="true" type="VARCHAR" size="24">
		<inheritance key="person" class="Person" extends="org.thdl.roster.om.Member"/>
		<inheritance key="project" class="Project" extends="org.thdl.roster.om.Member"/>
		<inheritance key="organization" class="Organization" extends="org.thdl.roster.om.Member"/>
	</column>
	<column name="person_data_id" type="INTEGER"/>
	<column name="project_data_id" type="INTEGER"/>
	<column name="organization_data_id" type="INTEGER"/>

	<foreign-key foreignTable="ContactInfo">
		<reference local="contact_info_id" foreign="id" />
	</foreign-key>
	<foreign-key foreignTable="ResearchInterest">
		<reference local="research_interest_id" foreign="id" />
	</foreign-key>
	<foreign-key foreignTable="Publication">
		<reference local="publication_id" foreign="id" />
	</foreign-key>
	<foreign-key foreignTable="PersonData">
		<reference local="person_data_id" foreign="id" />
	</foreign-key>
	<foreign-key foreignTable="ProjectData">
		<reference local="project_data_id" foreign="id" />
	</foreign-key>
	<foreign-key foreignTable="OrganizationData">
		<reference local="organization_data_id" foreign="id" />
	</foreign-key>
</table>
<table name="PersonData" >
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="thdl_user_id" required="true" type="INTEGER" description="Reference to external ThdlUsers Database"/>
	<column name="firstname" type="LONGVARCHAR"/>
	<column name="middlename" type="LONGVARCHAR"/>
	<column name="lastname" type="LONGVARCHAR"/>
	<column name="bio" type="CLOB"/>
	<column name="history" type="CLOB"/>
	<column name="parent_organization" type="LONGVARCHAR"/>
	<column name="school" type="LONGVARCHAR"/>
	<column name="department" type="LONGVARCHAR"/>
	<column name="program" type="LONGVARCHAR"/>
	<column name="advisor" type="LONGVARCHAR"/>
	<column name="highest_degree" type="LONGVARCHAR"/>
	<column name="year_began" type="INTEGER"/>
	<column name="year_finished" type="INTEGER"/>
	<column name="other_backgrounds" type="CLOB"/>
	<column name="organization" type="LONGVARCHAR"/>
	<column name="division" type="LONGVARCHAR"/>
	<column name="title" type="LONGVARCHAR"/>
	<column name="start_date" type="INTEGER"/>
	<column name="job_description" type="CLOB"/>
</table>
<table name="ProjectData">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="name" type="LONGVARCHAR"/>
	<column name="parent_organization" type="LONGVARCHAR"/>
	<column name="divisions" type="LONGVARCHAR"/>
	<column name="people" type="LONGVARCHAR"/>
	<column name="mailing_list" type="LONGVARCHAR"/>
	<column name="description" type="CLOB"/>
	<column name="history" type="CLOB"/>
	<column name="education_programs" type="CLOB"/>
	<column name="resources" type="CLOB"/>
</table>
<table name="OrganizationData">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="name" type="LONGVARCHAR"/>
	<column name="parent_organization" type="LONGVARCHAR"/>
	<column name="divisions" type="LONGVARCHAR"/>
	<column name="people" type="LONGVARCHAR"/>
	<column name="mailing_list" type="LONGVARCHAR"/>
	<column name="description" type="CLOB"/>
	<column name="history" type="CLOB"/>
	<column name="education_programs" type="CLOB"/>
	<column name="resources" type="CLOB"/>
</table>
<!-- roster-member-children -->
<table name="ContactInfo">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="contact_name" type="LONGVARCHAR"/>
	<column name="email" type="LONGVARCHAR"/>
	<column name="website" type="LONGVARCHAR"/>
	<column name="phone" type="INTEGER"/>
	<column name="fax" type="INTEGER"/>
	<column name="address_id" type="INTEGER"/>
	<foreign-key foreignTable="Address">
		<reference local="address_id" foreign="id"/>
	</foreign-key>
	<foreign-key foreignTable="Phone">
		<reference local="phone" foreign="id"/>
	</foreign-key>
	<foreign-key foreignTable="Phone">
		<reference local="fax" foreign="id"/>
	</foreign-key>
</table>
<table name="Address">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="address" type="LONGVARCHAR"/>
	<column name="city" type="LONGVARCHAR"/>
	<column name="region" type="LONGVARCHAR"/>
	<column name="zip" type="LONGVARCHAR"/>
	<column name="country_id" type="INTEGER"/>
	<foreign-key foreignTable="Country">
		<reference local="country_id" foreign="id"/>
	</foreign-key>
</table>
<table name="Phone">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="country_code" type="INTEGER"/>
	<column name="area_code" type="INTEGER"/>
	<column name="number" type="INTEGER"/>
</table>
<table name="Publication">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="formal_publications" type="CLOB"/>
	<column name="works_in_progress" type="CLOB"/>
	<column name="projects" type="CLOB"/>
</table>
<table name="ResearchInterest">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="interests" type="CLOB"/>
	<column name="activities" type="CLOB"/>
	<column name="collaboration_interests" type="CLOB"/>
	<column name="focus_from" type="INTEGER"/>
	<column name="focus_to" type="INTEGER"/>
</table>
<table name="Document">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="member_id" type="INTEGER"/>
	<column name="document_type_id" type="INTEGER"/>
	<column name="content_type" type="LONGVARCHAR"/>
	<column name="path" type="LONGVARCHAR"/>
	<column name="filename" type="LONGVARCHAR"/>
	<column name="label" type="LONGVARCHAR"/>
	<foreign-key foreignTable="Member">
		<reference local="member_id" foreign="id"/>
	</foreign-key>
	<foreign-key foreignTable="DocumentType">
		<reference local="document_type_id" foreign="id"/>
	</foreign-key>
</table>
<!--flat data-->
<table name="Country">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="country" required="true" type="LONGVARCHAR"/>
</table>
<table name="CulturalArea">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="cultural_area" required="true" type="LONGVARCHAR"/>
</table>
<table name="Language">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="language" required="true" type="LONGVARCHAR"/>
</table>
<table name="Discipline">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="discipline" required="true" type="LONGVARCHAR"/>
</table>
<table name="DocumentType">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="document_type" required="true" type="LONGVARCHAR"/>
</table>
<table name="ProjectType">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="project_type" required="true" type="LONGVARCHAR"/>
</table>
<table name="OrganizationType">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="organization_type" required="true" type="LONGVARCHAR"/>
</table>
<table name="PersonType">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="person_type" required="true" type="LONGVARCHAR"/>
</table>
<!-- merge tables -->
<table name="PersonPersonType">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="person_type_id" required="true" type="INTEGER"/>
	<column name="person_data_id" required="true" type="INTEGER"/>
	<column name="relevance" required="true" type="INTEGER"/>
	<foreign-key foreignTable="PersonData">
		<reference local="person_data_id" foreign="id" />
	</foreign-key>
	<foreign-key foreignTable="PersonType">
		<reference local="person_type_id" foreign="id" />
	</foreign-key>
</table>
<table name="OrganizationOrganizationType">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="organization_type_id" required="true" type="INTEGER"/>
	<column name="organization_data_id" required="true" type="INTEGER"/>
	<column name="relevance" required="true" type="INTEGER"/>
	<foreign-key foreignTable="OrganizationData">
		<reference local="organization_data_id" foreign="id" />
	</foreign-key>
	<foreign-key foreignTable="OrganizationType">
		<reference local="organization_type_id" foreign="id" />
	</foreign-key>
</table>
<table name="ProjectProjectType">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="project_type_id" required="true" type="INTEGER"/>
	<column name="project_data_id" required="true" type="INTEGER"/>
	<column name="relevance" required="true" type="INTEGER"/>
	<foreign-key foreignTable="ProjectData">
		<reference local="project_data_id" foreign="id" />
	</foreign-key>
	<foreign-key foreignTable="ProjectType">
		<reference local="project_type_id" foreign="id" />
	</foreign-key>
</table>
<table name="ResearchInterestLanguage">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="language_id" required="true" type="INTEGER"/>
	<column name="research_interest_id" required="true" type="INTEGER"/>
	<column name="relevance" required="true" type="INTEGER"/>
	<foreign-key foreignTable="ResearchInterest">
		<reference local="research_interest_id" foreign="id" />
	</foreign-key>
	<foreign-key foreignTable="Language">
		<reference local="language_id" foreign="id" />
	</foreign-key>
</table>
<table name="ResearchInterestCulturalArea">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="cultural_area_id" required="true" type="INTEGER"/>
	<column name="research_interest_id" required="true" type="INTEGER"/>
	<column name="relevance" required="true" type="INTEGER"/>
	<foreign-key foreignTable="ResearchInterest">
		<reference local="research_interest_id" foreign="id" />
	</foreign-key>
	<foreign-key foreignTable="CulturalArea">
		<reference local="cultural_area_id" foreign="id" />
	</foreign-key>
</table>
<table name="ResearchInterestDiscipline">
	<column name="id" primaryKey="true" required="true" type="INTEGER"/>
	<column name="discipline_id" required="true" type="INTEGER"/>
	<column name="research_interest_id" required="true" type="INTEGER"/>
	<column name="relevance" required="true" type="INTEGER"/>
	<foreign-key foreignTable="ResearchInterest">
		<reference local="research_interest_id" foreign="id" />
	</foreign-key>
	<foreign-key foreignTable="Discipline">
		<reference local="discipline_id" foreign="id" />
	</foreign-key>
</table>
</database>