     surnumerary boolean,
     CONSTRAINT pk_darwin_flat PRIMARY KEY (id),
     CONSTRAINT fk_darwin_flat_spec_ref FOREIGN KEY (spec_ref) REFERENCES specimens (id) ON DELETE CASCADE,
-    CONSTRAINT fk_darwin_flat_collection_ref FOREIGN KEY (collection_ref) REFERENCES collections (id) ON DELETE CASCADE,
-    CONSTRAINT fk_darwin_flat_collection_institution_ref FOREIGN KEY (collection_institution_ref) REFERENCES people (id) ON DELETE CASCADE,
-    CONSTRAINT fk_darwin_flat_collection_main_manager_ref FOREIGN KEY (collection_main_manager_ref) REFERENCES users (id) ON DELETE CASCADE,
+    CONSTRAINT fk_darwin_flat_collection_ref FOREIGN KEY (collection_ref) REFERENCES collections (id) ON DELETE SET DEFAULT,
+    CONSTRAINT fk_darwin_flat_collection_institution_ref FOREIGN KEY (collection_institution_ref) REFERENCES people (id) ON DELETE SET DEFAULT,
+    CONSTRAINT fk_darwin_flat_collection_main_manager_ref FOREIGN KEY (collection_main_manager_ref) REFERENCES users (id) ON DELETE SET DEFAULT,
     CONSTRAINT fk_darwin_flat_collection_parent_ref FOREIGN KEY (collection_parent_ref) REFERENCES collections (id) ON DELETE SET DEFAULT,
-    CONSTRAINT fk_darwin_flat_expedition_ref FOREIGN KEY (expedition_ref) REFERENCES expeditions (id) ON DELETE CASCADE,
-    CONSTRAINT fk_darwin_flat_gtu_ref FOREIGN KEY (gtu_ref) REFERENCES gtu (id) ON DELETE CASCADE,
+    CONSTRAINT fk_darwin_flat_expedition_ref FOREIGN KEY (expedition_ref) REFERENCES expeditions (id) ON DELETE SET DEFAULT,
+    CONSTRAINT fk_darwin_flat_gtu_ref FOREIGN KEY (gtu_ref) REFERENCES gtu (id) ON DELETE SET DEFAULT,
     CONSTRAINT fk_darwin_flat_gtu_parent_ref FOREIGN KEY (gtu_parent_ref) REFERENCES gtu (id) ON DELETE SET DEFAULT,
-    CONSTRAINT fk_darwin_flat_taxon_ref FOREIGN KEY (taxon_ref) REFERENCES taxonomy (id) ON DELETE CASCADE,
+    CONSTRAINT fk_darwin_flat_taxon_ref FOREIGN KEY (taxon_ref) REFERENCES taxonomy (id) ON DELETE SET DEFAULT,
     CONSTRAINT fk_darwin_flat_taxon_parent_ref FOREIGN KEY (taxon_parent_ref) REFERENCES taxonomy (id) ON DELETE SET DEFAULT,
-    CONSTRAINT fk_darwin_flat_taxon_level_ref FOREIGN KEY (taxon_level_ref) REFERENCES catalogue_levels (id) ON DELETE CASCADE,
-    CONSTRAINT fk_darwin_flat_chrono_ref FOREIGN KEY (chrono_ref) REFERENCES chronostratigraphy (id) ON DELETE CASCADE,
+    CONSTRAINT fk_darwin_flat_taxon_level_ref FOREIGN KEY (taxon_level_ref) REFERENCES catalogue_levels (id) ON DELETE SET DEFAULT,
+    CONSTRAINT fk_darwin_flat_chrono_ref FOREIGN KEY (chrono_ref) REFERENCES chronostratigraphy (id) ON DELETE SET DEFAULT,
     CONSTRAINT fk_darwin_flat_chrono_parent_ref FOREIGN KEY (chrono_parent_ref) REFERENCES chronostratigraphy (id) ON DELETE SET DEFAULT,
-    CONSTRAINT fk_darwin_flat_chrono_level_ref FOREIGN KEY (chrono_level_ref) REFERENCES catalogue_levels (id) ON DELETE CASCADE,
-    CONSTRAINT fk_darwin_flat_litho_ref FOREIGN KEY (litho_ref) REFERENCES lithostratigraphy (id) ON DELETE CASCADE,
+    CONSTRAINT fk_darwin_flat_chrono_level_ref FOREIGN KEY (chrono_level_ref) REFERENCES catalogue_levels (id) ON DELETE SET DEFAULT,
+    CONSTRAINT fk_darwin_flat_litho_ref FOREIGN KEY (litho_ref) REFERENCES lithostratigraphy (id) ON DELETE SET DEFAULT,
     CONSTRAINT fk_darwin_flat_litho_parent_ref FOREIGN KEY (litho_parent_ref) REFERENCES lithostratigraphy (id) ON DELETE SET DEFAULT,
-    CONSTRAINT fk_darwin_flat_litho_level_ref FOREIGN KEY (litho_level_ref) REFERENCES catalogue_levels (id) ON DELETE CASCADE,
-    CONSTRAINT fk_darwin_flat_lithology_ref FOREIGN KEY (lithology_ref) REFERENCES lithology (id) ON DELETE CASCADE,
+    CONSTRAINT fk_darwin_flat_litho_level_ref FOREIGN KEY (litho_level_ref) REFERENCES catalogue_levels (id) ON DELETE SET DEFAULT,
+    CONSTRAINT fk_darwin_flat_lithology_ref FOREIGN KEY (lithology_ref) REFERENCES lithology (id) ON DELETE SET DEFAULT,
     CONSTRAINT fk_darwin_flat_lithology_parent_ref FOREIGN KEY (lithology_parent_ref) REFERENCES lithology (id) ON DELETE SET DEFAULT,
-    CONSTRAINT fk_darwin_flat_lithology_level_ref FOREIGN KEY (lithology_level_ref) REFERENCES catalogue_levels (id) ON DELETE CASCADE,
-    CONSTRAINT fk_darwin_flat_mineral_ref FOREIGN KEY (mineral_ref) REFERENCES mineralogy (id) ON DELETE CASCADE,
+    CONSTRAINT fk_darwin_flat_lithology_level_ref FOREIGN KEY (lithology_level_ref) REFERENCES catalogue_levels (id) ON DELETE SET DEFAULT,
+    CONSTRAINT fk_darwin_flat_mineral_ref FOREIGN KEY (mineral_ref) REFERENCES mineralogy (id) ON DELETE SET DEFAULT,
     CONSTRAINT fk_darwin_flat_mineral_parent_ref FOREIGN KEY (mineral_parent_ref) REFERENCES mineralogy (id) ON DELETE SET DEFAULT,
-    CONSTRAINT fk_darwin_flat_mineral_level_ref FOREIGN KEY (mineral_level_ref) REFERENCES catalogue_levels (id) ON DELETE CASCADE,
+    CONSTRAINT fk_darwin_flat_mineral_level_ref FOREIGN KEY (mineral_level_ref) REFERENCES catalogue_levels (id) ON DELETE SET DEFAULT,
     CONSTRAINT fk_darwin_flat_host_taxon_ref FOREIGN KEY (host_taxon_ref) REFERENCES taxonomy (id) ON DELETE SET DEFAULT,
     CONSTRAINT fk_darwin_flat_host_taxon_parent_ref FOREIGN KEY (host_taxon_parent_ref) REFERENCES taxonomy (id) ON DELETE SET DEFAULT,
     CONSTRAINT fk_darwin_flat_host_taxon_level_ref FOREIGN KEY (host_taxon_level_ref) REFERENCES catalogue_levels (id) ON DELETE SET DEFAULT,

        password varchar,
        login_system varchar,
        last_seen timestamp,
        constraint pk_users_login_infos primary key (id),
        constraint unq_users_login_infos unique (user_ref, login_type),
        constraint fk_users_login_infos_users foreign key (user_ref) references users(id) on delete cascade
       );
comment on table users_login_infos is 'Contains the login/password informations of DaRWIN 2 users';

comment on column users_login_infos.password is 'For some system (local, ldap, kerberos,...) provides the password (encrypted form)';
comment on column users_login_infos.login_system is 'For some system (shibbolet, openID,...) provides the user id';
comment on column users_login_infos.last_seen is 'Last time the user has logged in.';
comment on column users_login_infos.renew_hash is 'Hashed key defined when asking to renew a password';
create table template_people_users_multimedia
       (
        person_user_ref integer not null,
