Schema
The best way to explore the database is to view a subset of rows in each table to get a general idea of the type of data. The following schema is provided to assist with writing queries.
Diagram
Database variables
The following is an exhaustive list of all table and column names within the database.
| table_name | column_name | data_type |
|---|---|---|
| aliases | alias_id | integer |
| aliases | individual_id | integer |
| aliases | alias_code | character varying |
| aliases | publication_doi | character varying |
| behavior_data | behavior_data_id | integer |
| behavior_data | behavior_sample_id | integer |
| behavior_data | behavior_data_time | timestamp without time zone |
| behavior_data | behavior_data_type | character varying |
| behavior_data | behavior_data_notes | character varying |
| behavior_data | duration | integer |
| behavior_data | constrained_duration | integer |
| behavior_data | behavior_data_time_stop | timestamp without time zone |
| behavior_observations | behavior_observation_id | integer |
| behavior_observations | behavior_data_id | integer |
| behavior_observations | observed_sequence | integer |
| behavior_observations | observation | character varying |
| behavior_observations | observation_category | character varying |
| behavior_observations | observed_partner | integer |
| behavior_observations | observed_direction | integer |
| behavior_observations | behavior_sample_notes | character varying |
| behavior_observations | geospatial | USER-DEFINED |
| behavior_observations | behavior_id | integer |
| behaviors | behavior_id | integer |
| behaviors | behavior_code | character |
| behaviors | behavior_name | character varying |
| behaviors | behavior_definition | character varying |
| behaviors | behavior_type | character varying |
| behaviors | notes | character varying |
| behavior_samples | behavior_sample_id | integer |
| behavior_samples | individual_id1 | integer |
| behavior_samples | researcher_id | integer |
| behavior_samples | behavior_sample_date | timestamp without time zone |
| behavior_samples | behavior_sample_notes | character varying |
| behavior_samples | individual_id2 | integer |
| behavior_samples | group_presence | character varying |
| behavior_samples | consort_id | integer |
| behavior_samples | group_activity | character varying |
| behavior_samples | location | character varying |
| behavior_samples | time_block | character varying |
| behavior_samples | estrous | boolean |
| behavior_samples | observation_session_id | integer |
| biosamples | biosample_id | integer |
| biosamples | individual_id | integer |
| biosamples | processing_id | integer |
| biosamples | biosample_timestamp | timestamp with time zone |
| biosamples | biosample_code | character varying |
| biosamples | researcher_id | integer |
| biosamples | biosample_type1 | character varying |
| biosamples | biosample_notes | character varying |
| biosamples | identification_flag | character varying |
| biosamples | grant_id | integer |
| biosamples | biosample_flag | character varying |
| biosamples | biosample_type2 | character varying |
| biosamples | elabs_code | character varying |
| biosamples | organ_weight_grams | numeric |
| biosamples | exhausted | boolean |
| biosamples | procedure_ids | ARRAY |
| biosamples | image_count | integer |
| biosamples | image_url | ARRAY |
| biosamples | date_created | timestamp without time zone |
| biosamples | date_modified | timestamp without time zone |
| census_data | census_data_id | integer |
| census_data | census_date | date |
| census_data | individual_id | integer |
| census_data | group_id | integer |
| census_data | census_notes | character varying |
| geography_columns | f_table_catalog | name |
| geography_columns | f_table_schema | name |
| geography_columns | f_table_name | name |
| geography_columns | f_geography_column | name |
| geography_columns | coord_dimension | integer |
| geography_columns | srid | integer |
| geography_columns | type | text |
| geometry_columns | f_table_catalog | character varying |
| geometry_columns | f_table_schema | name |
| geometry_columns | f_table_name | name |
| geometry_columns | f_geometry_column | name |
| geometry_columns | coord_dimension | integer |
| geometry_columns | srid | integer |
| geometry_columns | type | character varying |
| grants | grant_id | integer |
| grants | grant_label | character varying |
| grants | primary_contact | integer |
| grants | secondary_contact | integer |
| grants | grant_number | integer |
| grants | grant_agency | character varying |
| grants | grant_institute | character varying |
| grants | grant_division | character varying |
| grants | start_date | date |
| grants | end_date | date |
| grants | award_amount | numeric |
| grants | grant_notes | character varying |
| groups | group_id | integer |
| groups | group_name | character varying |
| groups | group_notes | character varying |
| groups_view | group_id | integer |
| groups_view | group_name | character varying |
| groups_view | group_notes | character varying |
| individual_life_histories | individual_life_history_id | integer |
| individual_life_histories | individual_id | integer |
| individual_life_histories | date | date |
| individual_life_histories | date_estimated | boolean |
| individual_life_histories | date_how_estimated | character varying |
| individual_life_histories | infant_id | integer |
| individual_life_histories | life_history_event | character varying |
| individual_life_histories | group_id | integer |
| individual_life_histories | individual_life_history_notes | character varying |
| individual_life_histories | life_history_flag | character varying |
| individual_life_histories | date_flag | character varying |
| individual_life_histories | created_at | timestamp with time zone |
| individual_life_histories | updated_at | timestamp with time zone |
| individual_ranks | individual_rank_id | integer |
| individual_ranks | individual_id | integer |
| individual_ranks | year | integer |
| individual_ranks | group_id | integer |
| individual_ranks | rank | integer |
| individual_ranks | ord_rank | character |
| individual_ranks | percent_dominated | numeric |
| individual_relationships | individual_relationship_id | integer |
| individual_relationships | individual_id | integer |
| individual_relationships | relationship_id | integer |
| individual_relationships | relationship_type | character varying |
| individual_relationships | individual_flag | character varying |
| individual_relationships | relationship_flag | character varying |
| individual_relationships | relationship_basis | character varying |
| individual_relationships | created_at | timestamp with time zone |
| individual_relationships | updated_at | timestamp with time zone |
| individuals | individual_id | integer |
| individuals | individual_code | character varying |
| individuals | individual_sex | character |
| individuals | individual_notes | character varying |
| individuals | individual_flag | character varying |
| individuals | infant_code | character varying |
| individuals | created_at | timestamp with time zone |
| individuals | updated_at | timestamp with time zone |
| individual_samples | individual_id | integer |
| individual_samples | individual_code | character varying |
| individual_samples | biosample_count | bigint |
| observation_sessions | device_id | character varying |
| observation_sessions | observation_session_start | timestamp without time zone |
| observation_sessions | observation_session_end | timestamp without time zone |
| observation_sessions | group_id | integer |
| observation_sessions | observation_session_notes | character varying |
| observation_sessions | grant_id | integer |
| observation_sessions | study | character varying |
| observation_sessions | observation_session_id | integer |
| procedures | procedure_id | integer |
| procedures | procedure_name | character varying |
| procedures | procedure_type | character varying |
| procedures | procedure_file | bytea |
| procedures | procedure_notes | character varying |
| processings | capture_code | character varying |
| processings | capture_timestamp | timestamp with time zone |
| processings | individual_id | integer |
| processings | processing_timestamp | timestamp with time zone |
| processings | processing_id | integer |
| processings | processing_notes | character varying |
| processings | processing_type | character varying |
| processings | transfer_date | date |
| processings | capture_notes | character varying |
| processings | body_weight_kgs | numeric |
| processings | processing_code | character varying |
| processings | blood_drawn_timestamp | timestamp with time zone |
| processings | recovered_timestamp | timestamp with time zone |
| processings | release_timestamp | timestamp with time zone |
| processings | procedure_ids | ARRAY |
| processings | group_id | integer |
| processings | image_count | integer |
| processings | image_url | ARRAY |
| processings | date_created | timestamp without time zone |
| processings | date_modified | timestamp without time zone |
| processing_steps | processing_step_id | integer |
| processing_steps | processing_id | integer |
| processing_steps | processing_step_time | timestamp with time zone |
| processing_steps | processing_dose | numeric |
| processing_steps | processing_step_type | character varying |
| raster_columns | r_table_catalog | name |
| raster_columns | r_table_schema | name |
| raster_columns | r_table_name | name |
| raster_columns | r_raster_column | name |
| raster_columns | srid | integer |
| raster_columns | scale_x | double precision |
| raster_columns | scale_y | double precision |
| raster_columns | blocksize_x | integer |
| raster_columns | blocksize_y | integer |
| raster_columns | same_alignment | boolean |
| raster_columns | regular_blocking | boolean |
| raster_columns | num_bands | integer |
| raster_columns | pixel_types | ARRAY |
| raster_columns | nodata_values | ARRAY |
| raster_columns | out_db | ARRAY |
| raster_columns | extent | USER-DEFINED |
| raster_columns | spatial_index | boolean |
| raster_overviews | o_table_catalog | name |
| raster_overviews | o_table_schema | name |
| raster_overviews | o_table_name | name |
| raster_overviews | o_raster_column | name |
| raster_overviews | r_table_catalog | name |
| raster_overviews | r_table_schema | name |
| raster_overviews | r_table_name | name |
| raster_overviews | r_raster_column | name |
| raster_overviews | overview_factor | integer |
| raw_files | raw_file_id | integer |
| raw_files | raw_file_year | integer |
| raw_files | group_id | integer |
| raw_files | raw_file_type | character varying |
| raw_files | raw_file | bytea |
| raw_files | raw_file_name | character varying |
| researchers | researcher_id | integer |
| researchers | first_name | character varying |
| researchers | last_name | character varying |
| researchers | line_manager | character varying |
| researchers | researcher_notes | character varying |
| spatial_ref_sys | srid | integer |
| spatial_ref_sys | auth_name | character varying |
| spatial_ref_sys | auth_srid | integer |
| spatial_ref_sys | srtext | character varying |
| spatial_ref_sys | proj4text | character varying |
Complete schema
This schema is provided in Postgresql syntax for recreating the database in it's entirety. For a more user friendly representation please refer to the table above.
CREATE TABLE public.aliases (
alias_id integer NOT NULL,
individual_id integer,
alias_code character varying(20) NOT NULL,
publication_doi character varying(20)
);
CREATE TABLE public.behavior_data (
behavior_data_id integer NOT NULL,
behavior_sample_id integer,
behavior_data_time timestamp without time zone,
behavior_data_type character varying,
behavior_data_notes character varying,
duration integer,
constrained_duration integer,
behavior_data_time_stop timestamp without time zone
);
CREATE TABLE public.behaviors (
behavior_id integer NOT NULL,
behavior_code character(5),
behavior_name character varying(40),
behavior_definition character varying(40),
behavior_type character varying(40),
notes character varying(200)
);
CREATE SEQUENCE public.behavior_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.behavior_id_seq OWNED BY public.behaviors.behavior_id;
CREATE TABLE public.behavior_observations (
behavior_observation_id integer NOT NULL,
behavior_data_id integer NOT NULL,
observed_sequence integer,
observation character varying(200),
observation_category character varying(20),
observed_partner integer,
observed_direction integer,
behavior_sample_notes character varying(200),
geospatial public.geometry,
behavior_id integer
);
CREATE TABLE public.behavior_samples (
behavior_sample_id integer NOT NULL,
individual_id1 integer NOT NULL,
researcher_id integer,
behavior_sample_date timestamp without time zone,
behavior_sample_notes character varying,
individual_id2 integer,
group_presence character varying,
consort_id integer,
group_activity character varying,
location character varying,
time_block character varying,
estrous boolean,
observation_session_id integer
);
CREATE SEQUENCE public.behaviordata_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.behaviordata_id_seq OWNED BY public.behavior_data.behavior_data_id;
CREATE SEQUENCE public.behaviorobservation_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.behaviorobservation_id_seq OWNED BY public.behavior_observations.behavior_observation_id;
CREATE SEQUENCE public.behaviorsample_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.behaviorsample_id_seq OWNED BY public.behavior_samples.behavior_sample_id;
CREATE TABLE public.biosamples (
biosample_id integer NOT NULL,
individual_id integer,
processing_id integer,
biosample_timestamp timestamp with time zone,
biosample_code character varying(35),
researcher_id integer,
biosample_type1 character varying(35),
biosample_notes character varying(200),
identification_flag character varying(20),
grant_id integer,
biosample_flag character varying(20),
biosample_type2 character varying(35),
elabs_code character varying(20),
organ_weight_grams numeric,
exhausted boolean,
procedure_ids integer[],
image_count integer,
image_url character varying[],
date_created timestamp without time zone DEFAULT now() NOT NULL,
date_modified timestamp without time zone
);
CREATE SEQUENCE public.biosample_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.biosample_id_seq OWNED BY public.biosamples.biosample_id;
CREATE TABLE public.census_data (
census_data_id integer NOT NULL,
census_date date,
individual_id integer,
group_id integer,
census_notes character varying(200)
);
CREATE SEQUENCE public.census_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.census_id_seq OWNED BY public.census_data.census_data_id;
CREATE TABLE public.grants (
grant_id integer NOT NULL,
grant_label character varying(35) NOT NULL,
primary_contact integer,
secondary_contact integer,
grant_number integer,
grant_agency character varying(35),
grant_institute character varying(125),
grant_division character varying(35),
start_date date,
end_date date,
award_amount numeric,
grant_notes character varying(200)
);
CREATE SEQUENCE public.grant_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.grant_id_seq OWNED BY public.grants.grant_id;
CREATE TABLE public.groups (
group_id integer NOT NULL,
group_name character varying(20) NOT NULL,
group_notes character varying(200)
);
CREATE SEQUENCE public.group_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.group_id_seq OWNED BY public.groups.group_id;
CREATE TABLE public.individuals (
individual_id integer NOT NULL,
individual_code character varying(20),
individual_sex character(1),
individual_notes character varying(200),
individual_flag character varying(40),
infant_code character varying(20),
created_at timestamp with time zone DEFAULT now(),
updated_at timestamp with time zone DEFAULT now()
);
CREATE SEQUENCE public.individual_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.individual_id_seq OWNED BY public.individuals.individual_id;
CREATE TABLE public.individual_life_histories (
individual_life_history_id integer NOT NULL,
individual_id integer NOT NULL,
date date,
date_estimated boolean,
date_how_estimated character varying(20),
infant_id integer,
life_history_event character varying(20),
group_id integer,
individual_life_history_notes character varying(200),
life_history_flag character varying(20),
date_flag character varying(20),
created_at timestamp with time zone DEFAULT now(),
updated_at timestamp with time zone DEFAULT now()
);
CREATE TABLE public.individual_ranks (
individual_rank_id integer NOT NULL,
individual_id integer NOT NULL,
year integer,
group_id integer,
rank integer,
ord_rank character(1),
percent_dominated numeric
);
CREATE SEQUENCE public.individual_rank_rank_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.individual_rank_rank_id_seq OWNED BY public.individual_ranks.individual_rank_id;
CREATE TABLE public.individual_relationships (
individual_relationship_id integer NOT NULL,
individual_id integer,
relationship_id integer,
relationship_type character varying(11),
individual_flag character varying(50),
relationship_flag character varying(30),
relationship_basis character varying(200),
created_at timestamp with time zone DEFAULT now(),
updated_at timestamp with time zone DEFAULT now()
);
CREATE SEQUENCE public.individual_relationship_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.individual_relationship_id_seq OWNED BY public.individual_relationships.individual_relationship_id;
CREATE SEQUENCE public.life_history_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.life_history_id_seq OWNED BY public.individual_life_histories.individual_life_history_id;
CREATE TABLE public.observation_sessions (
device_id character varying(20),
observation_session_start timestamp without time zone,
observation_session_end timestamp without time zone,
group_id integer,
observation_session_notes character varying(200),
grant_id integer,
study character varying(50),
observation_session_id integer NOT NULL
);
CREATE SEQUENCE public.observation_sessions_observationsession_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.observation_sessions_observationsession_id_seq OWNED BY public.observation_sessions.observation_session_id;
CREATE TABLE public.procedures (
procedure_id integer NOT NULL,
procedure_name character varying(45) NOT NULL,
procedure_type character varying(45),
procedure_file bytea,
procedure_notes character varying(200)
);
CREATE SEQUENCE public.procedures_procedure_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.procedures_procedure_id_seq OWNED BY public.procedures.procedure_id;
CREATE TABLE public.processings (
capture_code character varying(20),
capture_timestamp timestamp with time zone,
individual_id integer NOT NULL,
processing_timestamp timestamp with time zone,
processing_id integer NOT NULL,
processing_notes character varying(400),
processing_type character varying(20),
transfer_date date,
capture_notes character varying(400),
body_weight_kgs numeric,
processing_code character varying,
blood_drawn_timestamp timestamp with time zone,
recovered_timestamp timestamp with time zone,
release_timestamp timestamp with time zone,
procedure_ids integer[],
group_id integer,
image_count integer,
image_url character varying[],
date_created timestamp without time zone DEFAULT now() NOT NULL,
date_modified timestamp without time zone
);
CREATE SEQUENCE public.processing_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.processing_id_seq OWNED BY public.processings.processing_id;
CREATE TABLE public.processing_steps (
processing_step_id integer NOT NULL,
processing_id integer NOT NULL,
processing_step_time timestamp with time zone,
processing_dose numeric,
processing_step_type character varying(20)
);
CREATE SEQUENCE public.processingstep_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.processingstep_id_seq OWNED BY public.processing_steps.processing_step_id;
CREATE TABLE public.raw_files (
raw_file_id integer NOT NULL,
raw_file_year integer,
group_id integer,
raw_file_type character varying(30),
raw_file bytea,
raw_file_name character varying(50)
);
CREATE SEQUENCE public.raw_files_raw_file_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.raw_files_raw_file_id_seq OWNED BY public.raw_files.raw_file_id;
CREATE TABLE public.researchers (
researcher_id integer NOT NULL,
first_name character varying(35) NOT NULL,
last_name character varying(35),
line_manager character varying(70),
researcher_notes character varying(200)
);
CREATE SEQUENCE public.researcher_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.researcher_id_seq OWNED BY public.researchers.researcher_id;
CREATE TABLE public.upload_infantid_mapping_birthcohorts_2014_2022_m_20240116063954 (
animalid character varying(255),
dob character varying(255),
birthseason integer,
sex character varying(255),
behaviormom character varying(255),
"group" character varying(255),
infantid character varying(255)
);
ALTER TABLE ONLY public.behavior_data ALTER COLUMN behavior_data_id SET DEFAULT nextval('public.behaviordata_id_seq'::regclass);
ALTER TABLE ONLY public.behavior_observations ALTER COLUMN behavior_observation_id SET DEFAULT nextval('public.behaviorobservation_id_seq'::regclass);
ALTER TABLE ONLY public.behavior_samples ALTER COLUMN behavior_sample_id SET DEFAULT nextval('public.behaviorsample_id_seq'::regclass);
ALTER TABLE ONLY public.behaviors ALTER COLUMN behavior_id SET DEFAULT nextval('public.behavior_id_seq'::regclass);
ALTER TABLE ONLY public.biosamples ALTER COLUMN biosample_id SET DEFAULT nextval('public.biosample_id_seq'::regclass);
ALTER TABLE ONLY public.census_data ALTER COLUMN census_data_id SET DEFAULT nextval('public.census_id_seq'::regclass);
ALTER TABLE ONLY public.grants ALTER COLUMN grant_id SET DEFAULT nextval('public.grant_id_seq'::regclass);
ALTER TABLE ONLY public.groups ALTER COLUMN group_id SET DEFAULT nextval('public.group_id_seq'::regclass);
ALTER TABLE ONLY public.individual_life_histories ALTER COLUMN individual_life_history_id SET DEFAULT nextval('public.life_history_id_seq'::regclass);
ALTER TABLE ONLY public.individual_ranks ALTER COLUMN individual_rank_id SET DEFAULT nextval('public.individual_rank_rank_id_seq'::regclass);
ALTER TABLE ONLY public.individual_relationships ALTER COLUMN individual_relationship_id SET DEFAULT nextval('public.individual_relationship_id_seq'::regclass);
ALTER TABLE ONLY public.individuals ALTER COLUMN individual_id SET DEFAULT nextval('public.individual_id_seq'::regclass);
ALTER TABLE ONLY public.observation_sessions ALTER COLUMN observation_session_id SET DEFAULT nextval('public.observation_sessions_observationsession_id_seq'::regclass);
ALTER TABLE ONLY public.procedures ALTER COLUMN procedure_id SET DEFAULT nextval('public.procedures_procedure_id_seq'::regclass);
ALTER TABLE ONLY public.processing_steps ALTER COLUMN processing_step_id SET DEFAULT nextval('public.processingstep_id_seq'::regclass);
ALTER TABLE ONLY public.processings ALTER COLUMN processing_id SET DEFAULT nextval('public.processing_id_seq'::regclass);
ALTER TABLE ONLY public.raw_files ALTER COLUMN raw_file_id SET DEFAULT nextval('public.raw_files_raw_file_id_seq'::regclass);
ALTER TABLE ONLY public.researchers ALTER COLUMN researcher_id SET DEFAULT nextval('public.researcher_id_seq'::regclass);
ALTER TABLE ONLY public.aliases
ADD CONSTRAINT alias_pkey PRIMARY KEY (alias_code);
ALTER TABLE ONLY public.behavior_data
ADD CONSTRAINT behavior_data_pkey PRIMARY KEY (behavior_data_id);
ALTER TABLE ONLY public.behaviors
ADD CONSTRAINT behavior_id_pkey PRIMARY KEY (behavior_id);
ALTER TABLE ONLY public.behavior_observations
ADD CONSTRAINT behavior_observations_pkey PRIMARY KEY (behavior_observation_id);
ALTER TABLE ONLY public.behavior_samples
ADD CONSTRAINT behavior_samples_pkey PRIMARY KEY (behavior_sample_id);
ALTER TABLE ONLY public.biosamples
ADD CONSTRAINT biological_samples_pkey PRIMARY KEY (biosample_id);
ALTER TABLE ONLY public.census_data
ADD CONSTRAINT census_data_pkey PRIMARY KEY (census_data_id);
ALTER TABLE ONLY public.grants
ADD CONSTRAINT grant_ids_pkey PRIMARY KEY (grant_id);
ALTER TABLE ONLY public.groups
ADD CONSTRAINT group_id_pkey PRIMARY KEY (group_id);
ALTER TABLE ONLY public.individual_life_histories
ADD CONSTRAINT individual_life_history_pkey PRIMARY KEY (individual_life_history_id);
ALTER TABLE ONLY public.individual_ranks
ADD CONSTRAINT individual_rank_pkey PRIMARY KEY (individual_rank_id);
ALTER TABLE ONLY public.individuals
ADD CONSTRAINT individuals_pkey PRIMARY KEY (individual_id);
ALTER TABLE ONLY public.individual_relationships
ADD CONSTRAINT individuals_relationship_pkey PRIMARY KEY (individual_relationship_id);
ALTER TABLE ONLY public.observation_sessions
ADD CONSTRAINT observation_sessions_pkey PRIMARY KEY (observation_session_id);
ALTER TABLE ONLY public.procedures
ADD CONSTRAINT procedures_pkey PRIMARY KEY (procedure_id);
ALTER TABLE ONLY public.processings
ADD CONSTRAINT processing_data_pkey PRIMARY KEY (processing_id);
ALTER TABLE ONLY public.processing_steps
ADD CONSTRAINT processing_step_key PRIMARY KEY (processing_step_id);
ALTER TABLE ONLY public.raw_files
ADD CONSTRAINT raw_files_pkey PRIMARY KEY (raw_file_id);
ALTER TABLE ONLY public.researchers
ADD CONSTRAINT researcher_ids_pkey PRIMARY KEY (researcher_id);
ALTER TABLE ONLY public.behaviors
ADD CONSTRAINT unique_behavior_code UNIQUE (behavior_code);
ALTER TABLE ONLY public.behaviors
ADD CONSTRAINT unique_behavior_name UNIQUE (behavior_name);
ALTER TABLE ONLY public.grants
ADD CONSTRAINT unique_grant_label UNIQUE (grant_label);
ALTER TABLE ONLY public.groups
ADD CONSTRAINT unique_group_name UNIQUE (group_name);
ALTER TABLE ONLY public.behavior_samples
ADD CONSTRAINT behavior_samples_obssession_id_fkey FOREIGN KEY (observation_session_id) REFERENCES public.observation_sessions(observation_session_id);
ALTER TABLE ONLY public.behavior_observations
ADD CONSTRAINT behaviordata_fkey FOREIGN KEY (behavior_data_id) REFERENCES public.behavior_data(behavior_data_id) NOT VALID;
ALTER TABLE ONLY public.behavior_observations
ADD CONSTRAINT behaviorref_fkey FOREIGN KEY (behavior_id) REFERENCES public.behaviors(behavior_id) NOT VALID;
ALTER TABLE ONLY public.behavior_data
ADD CONSTRAINT behaviorsample_fkey FOREIGN KEY (behavior_sample_id) REFERENCES public.behavior_samples(behavior_sample_id) NOT VALID;
ALTER TABLE ONLY public.biosamples
ADD CONSTRAINT collected_by FOREIGN KEY (researcher_id) REFERENCES public.researchers(researcher_id) NOT VALID;
ALTER TABLE ONLY public.biosamples
ADD CONSTRAINT grant_id FOREIGN KEY (grant_id) REFERENCES public.grants(grant_id) NOT VALID;
ALTER TABLE ONLY public.observation_sessions
ADD CONSTRAINT grant_id FOREIGN KEY (grant_id) REFERENCES public.grants(grant_id) NOT VALID;
ALTER TABLE ONLY public.individual_ranks
ADD CONSTRAINT group_fkey FOREIGN KEY (group_id) REFERENCES public.groups(group_id) NOT VALID;
ALTER TABLE ONLY public.census_data
ADD CONSTRAINT group_id FOREIGN KEY (group_id) REFERENCES public.groups(group_id) NOT VALID;
ALTER TABLE ONLY public.individual_life_histories
ADD CONSTRAINT group_id FOREIGN KEY (group_id) REFERENCES public.groups(group_id) NOT VALID;
ALTER TABLE ONLY public.observation_sessions
ADD CONSTRAINT group_id FOREIGN KEY (group_id) REFERENCES public.groups(group_id) NOT VALID;
ALTER TABLE ONLY public.processings
ADD CONSTRAINT group_id FOREIGN KEY (group_id) REFERENCES public.groups(group_id) NOT VALID;
ALTER TABLE ONLY public.aliases
ADD CONSTRAINT individual_id FOREIGN KEY (alias_id) REFERENCES public.individuals(individual_id);
ALTER TABLE ONLY public.processings
ADD CONSTRAINT individual_id FOREIGN KEY (individual_id) REFERENCES public.individuals(individual_id) NOT VALID;
ALTER TABLE ONLY public.biosamples
ADD CONSTRAINT individual_id FOREIGN KEY (individual_id) REFERENCES public.individuals(individual_id) NOT VALID;
ALTER TABLE ONLY public.behavior_samples
ADD CONSTRAINT individual_id FOREIGN KEY (individual_id1) REFERENCES public.individuals(individual_id) NOT VALID;
ALTER TABLE ONLY public.census_data
ADD CONSTRAINT individual_id FOREIGN KEY (individual_id) REFERENCES public.individuals(individual_id) NOT VALID;
ALTER TABLE ONLY public.individual_life_histories
ADD CONSTRAINT individual_id FOREIGN KEY (individual_id) REFERENCES public.individuals(individual_id) NOT VALID;
ALTER TABLE ONLY public.behavior_samples
ADD CONSTRAINT individual_id2 FOREIGN KEY (individual_id2) REFERENCES public.individuals(individual_id) NOT VALID;
ALTER TABLE ONLY public.individual_ranks
ADD CONSTRAINT individuals_fkey FOREIGN KEY (individual_id) REFERENCES public.individuals(individual_id) NOT VALID;
ALTER TABLE ONLY public.individual_relationships
ADD CONSTRAINT indvidual_id FOREIGN KEY (individual_id) REFERENCES public.individuals(individual_id);
ALTER TABLE ONLY public.individual_life_histories
ADD CONSTRAINT infant_id FOREIGN KEY (infant_id) REFERENCES public.individuals(individual_id) NOT VALID;
ALTER TABLE ONLY public.grants
ADD CONSTRAINT primary_contact FOREIGN KEY (primary_contact) REFERENCES public.researchers(researcher_id) NOT VALID;
ALTER TABLE ONLY public.biosamples
ADD CONSTRAINT processing_id FOREIGN KEY (processing_id) REFERENCES public.processings(processing_id) NOT VALID;
ALTER TABLE ONLY public.processing_steps
ADD CONSTRAINT processingid_fkey FOREIGN KEY (processing_id) REFERENCES public.processings(processing_id) NOT VALID;
ALTER TABLE ONLY public.raw_files
ADD CONSTRAINT raw_group_fkey FOREIGN KEY (group_id) REFERENCES public.groups(group_id) NOT VALID;
ALTER TABLE ONLY public.individual_relationships
ADD CONSTRAINT relation_id FOREIGN KEY (relationship_id) REFERENCES public.individuals(individual_id);
ALTER TABLE ONLY public.behavior_samples
ADD CONSTRAINT researcher_id FOREIGN KEY (researcher_id) REFERENCES public.researchers(researcher_id) NOT VALID;
ALTER TABLE ONLY public.grants
ADD CONSTRAINT secondary_contact FOREIGN KEY (secondary_contact) REFERENCES public.researchers(researcher_id) NOT VALID;
