Commit 65e1e7f5 authored by Romain Loth's avatar Romain Loth

planned changes for comex_shared DB structure

parent b3da7e32
......@@ -8,7 +8,10 @@ mysql -uroot -pvery-safe-pass -h $SQL_HOST -P 3306
CREATE DATABASE comex_shared CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE comex_shared ;
CREATE TABLE scholars (
doors_uid char(36) not null unique primary key,
-- local uid necessary for users who still have no doors_uid
luid int(15) not null auto_increment unique primary key,
-- doors uid common to all lab's services
doors_uid char(36) not null unique,
last_modified_date char(24) not null,
email varchar(255) not null unique,
country varchar(60) not null,
......@@ -20,7 +23,6 @@ CREATE TABLE scholars (
position varchar(30), -- eg Director
hon_title varchar(30), -- eg Doctor
interests_text varchar(1200),
community_hashtags varchar(350),
gender char(1),
job_looking_date char(24), -- null if not looking for a job
home_url varchar(120), -- homepage
......@@ -28,9 +30,11 @@ CREATE TABLE scholars (
pic_file mediumblob,
record_status varchar(10),
INDEX uid_index_sch (doors_uid),
INDEX country_index_sch (country),
INDEX luid_index_sch (luid),
INDEX duid_index_sch (doors_uid),
INDEX affs_index_sch (affiliation_id)
INDEX country_index_sch (country),
INDEX status_index_sch (record_status)
) ;
-- affiliations: institutions and labs
......@@ -42,10 +46,8 @@ CREATE TABLE affiliations(
org_city varchar(50),
INDEX affid_index_affs (affid),
PRIMARY KEY (affid),
-- we chose not to put org_type in unique key: should be entailed by other 3
-- TODO doesn't yet prevent entering the same info twice !!
UNIQUE KEY full_affiliation (org, team_lab, org_city)
UNIQUE KEY full_affiliation (org, team_lab, org_city, org_type)
-- NB org_type should be entailed by other 3 in business logic
);
ALTER TABLE scholars ADD FOREIGN KEY (affiliation_id) REFERENCES affiliations(affid) ;
......@@ -61,24 +63,44 @@ CREATE TABLE keywords(
-- relationship scholars <n=n> keywords
CREATE TABLE sch_kw(
uid char(36) not null,
uid int(15) not null,
kwid int(15) not null,
INDEX uid_index_schkw (uid),
INDEX kwid_index_schkw (kwid),
PRIMARY KEY (uid, kwid),
FOREIGN KEY (uid) REFERENCES scholars(doors_uid) ON DELETE CASCADE,
FOREIGN KEY (uid) REFERENCES scholars(luid) ON DELETE CASCADE,
FOREIGN KEY (kwid) REFERENCES keywords(kwid)
);
-- hashtag/workgroup terms
CREATE TABLE hashtags(
htid int(15) not null auto_increment,
htstr char(50) not null unique, -- eg '#dataviz'
INDEX htid_index_hts (htid),
INDEX htstr_index_hts (htstr),
PRIMARY KEY (htid)
);
-- relationship scholars <n=n> hashtags
CREATE TABLE sch_ht(
uid int(15) not null,
htid int(15) not null,
INDEX uid_index_schht (uid),
INDEX htid_index_schht (htid),
PRIMARY KEY (uid, htid),
FOREIGN KEY (uid) REFERENCES scholars(luid) ON DELETE CASCADE,
FOREIGN KEY (htid) REFERENCES hashtags(htid)
);
-- linked identities (various users' ids on soc. media and research networks)
-- TODO use this :)
CREATE TABLE linked_ids(
linkid int(15) not null auto_increment,
uid char(36) not null,
uid int(15) not null,
ext_id_type char(50) not null, -- eg 'orcid','LinkedIn','Twitter'
ext_id char(50) not null, -- eg "0000-0002-1825-0097"
INDEX uid_index_eids (uid),
PRIMARY KEY (linkid),
FOREIGN KEY (uid) REFERENCES scholars(doors_uid) ON DELETE CASCADE
FOREIGN KEY (uid) REFERENCES scholars(luid) ON DELETE CASCADE
);
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment