Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
david Chavalarias
clinicaltrials
Commits
4f53c2b8
Commit
4f53c2b8
authored
Mar 07, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DB planned changes for new labs/institutions structure
parent
996180dc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
123 additions
and
31 deletions
+123
-31
README.md
README.md
+7
-5
table_specifications.md
doc/table_specifications.md
+59
-13
init_comex_shared.sql
setup/dockers/comex2_mysql_server/init_comex_shared.sql
+57
-13
No files found.
README.md
View file @
4f53c2b8
...
...
@@ -102,8 +102,8 @@ Uploaded images are in `data/shared_user_img`.
-
a unique external doors_uid (the user id for the entire lab)
-
a unique email
-
we have four related tables
-
`
affiliation
s`
for labs and institutions
-
(directly pointed by an
**affiliation_id**
in scholars table)
-
`
org
s`
for labs and institutions
-
and sch_org for scholars
<
=
>
organisms mapping
-
`keywords`
-
and
`sch_kw`
for scholars
<
=
>
keywords mapping
-
`hashtags`
...
...
@@ -123,8 +123,10 @@ SELECT
scholars.*,
affiliations.*,
FROM scholars
LEFT JOIN affiliations
ON affiliation_id = affid
LEFT JOIN sch_org
ON luid = sch_org.uid
JOIN orgs
ON orgs.orgid = sch_org.orgid
-- ==================================
...
...
@@ -136,7 +138,7 @@ SELECT
GROUP_CONCAT(kwstr) AS keywords_list
FROM scholars
JOIN sch_kw
ON
doors_
uid = uid
ON
l
uid = uid
JOIN keywords
ON sch_kw.kwid = keywords.kwid
GROUP BY uid ;
...
...
doc/table_specifications.md
View file @
4f53c2b8
...
...
@@ -26,7 +26,6 @@ CREATE TABLE scholars (
middle_name varchar(30),
last_name varchar(50) not null,
initials varchar(7) not null,
affiliation_id int(15) not null,
position varchar(120), -- eg Director
hon_title varchar(30), -- eg Doctor
interests_text varchar(3500),
...
...
@@ -42,25 +41,72 @@ CREATE TABLE scholars (
future_reserved varchar(30), -- eg for an imported id or temp status
INDEX duid_index_sch (doors_uid),
INDEX affs_index_sch (affiliation_id),
INDEX country_index_sch (country),
INDEX rstatus_index_sch (record_status)
) ;
-- affiliations: institutions and labs
CREATE TABLE affiliations(
affid int(15) not null auto_increment,
org varchar(120),
org_type varchar(50),
team_lab varchar(120) not null,
CREATE TABLE locs(
locname varchar(120),
lat float(6,4),
lng float(7,4), -- 4 decimals for lat & lng <=> 100m resol
PRIMARY KEY (locname)
) ;
-- table for all organization classes (team, lab, large institution)
CREATE TABLE orgs(
orgid int(15) not null auto_increment,
name varchar(120), -- full name
acro varchar(20), -- acronym or short name
class varchar(25), -- "team|lab|inst"
-- like the calibre of the organization
lab_code varchar(25), -- ex "UPS 3611" or "UMR 9221" (iff lab)
inst_type varchar(50), -- ex "public org|private org" (iff inst)
locname varchar(120) null, -- ex "Paris, France" or "France"
-- (key to more info in table locs)
url varchar(180), -- the organisation's homepage
contact_email varchar(255), -- if some email
contact_name varchar(80), -- if some administrative contact person
timestamp timestamp,
-- address... (...) -- address elements POSS NOT IMPLEMENTED
reserved varchar(30),
reserved varchar(30),
PRIMARY KEY (affid),
UNIQUE KEY full_affiliation (org, team_lab, org_city, org_type)
-- generated column, often useful for autocompletes etc
-- ex "Instituto de Fisica de Cantabria (IFCA), Santander, Spain"
tostring varchar(800) AS (CONCAT(
name, ' (', acro, ')',
IF(locname IS NOT NULL ,
CONCAT(', ', locname),
'')
)),
PRIMARY KEY (orgid),
UNIQUE KEY full_org (name, acro, locname)
-- POSS FOREIGN KEY locname REFERENCES locs(locname)
-- (useful when we use the locs more in the app)
) ;
-- relationship scholars <n=n> organizations
CREATE TABLE sch_org(
uid int(15) not null,
orgid int(15) not null,
PRIMARY KEY (uid, orgid),
FOREIGN KEY (uid) REFERENCES scholars(luid) ON DELETE CASCADE,
FOREIGN KEY (orgid) REFERENCES orgs(orgid)
);
-- POSS: relationship organizations <=> keywords
-- POSS: relationship organizations <=> organizations
-- keyword/subject terms
CREATE TABLE keywords(
...
...
setup/dockers/comex2_mysql_server/init_comex_shared.sql
View file @
4f53c2b8
...
...
@@ -19,7 +19,6 @@ CREATE TABLE scholars (
middle_name
varchar
(
30
),
last_name
varchar
(
50
)
not
null
,
initials
varchar
(
7
)
not
null
,
affiliation_id
int
(
15
)
not
null
,
position
varchar
(
120
),
-- eg Director
hon_title
varchar
(
30
),
-- eg Doctor
interests_text
varchar
(
3500
),
...
...
@@ -35,25 +34,70 @@ CREATE TABLE scholars (
future_reserved
varchar
(
30
),
-- eg for an imported id or temp status
INDEX
duid_index_sch
(
doors_uid
),
INDEX
affs_index_sch
(
affiliation_id
),
INDEX
country_index_sch
(
country
),
INDEX
rstatus_index_sch
(
record_status
)
)
;
-- affiliations: institutions and labs
CREATE
TABLE
affiliations
(
affid
int
(
15
)
not
null
auto_increment
,
org
varchar
(
120
),
org_type
varchar
(
50
),
team_lab
varchar
(
120
)
not
null
,
CREATE
TABLE
locs
(
locname
varchar
(
120
),
lat
float
(
6
,
4
),
lng
float
(
7
,
4
),
-- 4 decimals for lat & lng <=> 100m resol
PRIMARY
KEY
(
locname
)
)
;
-- table for all organization classes (team, lab, large institution)
CREATE
TABLE
orgs
(
orgid
int
(
15
)
not
null
auto_increment
,
name
varchar
(
120
),
-- full name
acro
varchar
(
20
),
-- acronym or short name
class
varchar
(
25
),
-- "team|lab|inst"
-- like the calibre of the organization
lab_code
varchar
(
25
),
-- ex "UPS 3611" or "UMR 9221" (iff lab)
inst_type
varchar
(
50
),
-- ex "public org|private org" (iff inst)
locname
varchar
(
120
)
null
,
-- ex "Paris, France" or "France"
-- (key to more info in table locs)
url
varchar
(
180
),
-- the organisation's homepage
contact_email
varchar
(
255
),
-- if some email
contact_name
varchar
(
80
),
-- if some administrative contact person
timestamp
timestamp
,
-- address... (...) -- address elements POSS NOT IMPLEMENTED
reserved
varchar
(
30
),
reserved
varchar
(
30
),
PRIMARY
KEY
(
affid
),
UNIQUE
KEY
full_affiliation
(
org
,
team_lab
,
org_city
,
org_type
)
-- generated column, often useful for autocompletes etc
-- ex "Instituto de Fisica de Cantabria (IFCA), Santander, Spain"
tostring
varchar
(
800
)
AS
(
CONCAT
(
name
,
' ('
,
acro
,
')'
,
IF
(
locname
IS
NOT
NULL
,
CONCAT
(
', '
,
locname
),
''
)
)),
PRIMARY
KEY
(
orgid
),
UNIQUE
KEY
full_org
(
name
,
acro
,
locname
)
-- POSS FOREIGN KEY locname REFERENCES locs(locname)
-- (useful when we use the locs more in the app)
)
;
-- relationship scholars <n=n> organizations
CREATE
TABLE
sch_org
(
uid
int
(
15
)
not
null
,
orgid
int
(
15
)
not
null
,
PRIMARY
KEY
(
uid
,
orgid
),
FOREIGN
KEY
(
uid
)
REFERENCES
scholars
(
luid
)
ON
DELETE
CASCADE
,
FOREIGN
KEY
(
orgid
)
REFERENCES
orgs
(
orgid
)
);
-- POSS: relationship organizations <=> keywords
-- POSS: relationship organizations <=> organizations
-- keyword/subject terms
CREATE
TABLE
keywords
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment