Project

General

Profile

« Previous | Next » 

Revision 5399

schemas/vegbien.sql: taxonconcept: Renamed canon_taxonconcept_id to canon_concept_id to shorten the name, which is used often

View differences:

vegbien.sql
253 253
-- Name: _set_canon_taxonconcept(integer, integer); Type: FUNCTION; Schema: public; Owner: -
254 254
--
255 255

  
256
CREATE FUNCTION _set_canon_taxonconcept(taxonconcept_id integer, canon_taxonconcept_id integer) RETURNS integer
256
CREATE FUNCTION _set_canon_taxonconcept(taxonconcept_id integer, canon_concept_id integer) RETURNS integer
257 257
    LANGUAGE sql
258 258
    AS $_$
259
UPDATE taxonconcept SET canon_taxonconcept_id = $2 WHERE taxonconcept_id = $1
259
UPDATE taxonconcept SET canon_concept_id = $2 WHERE taxonconcept_id = $1
260 260
RETURNING taxonconcept_id
261 261
$_$;
262 262

  
......
377 377

  
378 378

  
379 379
--
380
-- Name: taxonconcept_canon_taxonconcept_id_self_ref(); Type: FUNCTION; Schema: public; Owner: -
380
-- Name: taxonconcept_canon_concept_id_self_ref(); Type: FUNCTION; Schema: public; Owner: -
381 381
--
382 382

  
383
CREATE FUNCTION taxonconcept_canon_taxonconcept_id_self_ref() RETURNS trigger
383
CREATE FUNCTION taxonconcept_canon_concept_id_self_ref() RETURNS trigger
384 384
    LANGUAGE plpgsql
385 385
    AS $$
386 386
BEGIN
387 387
    IF new.taxonconcept_id IS NULL THEN -- prepopulate taxonconcept_id
388 388
        new.taxonconcept_id = nextval('taxonconcept_taxonconcept_id_seq'::regclass);
389 389
    END IF;
390
    IF new.canon_taxonconcept_id = 0 THEN -- make self-reference
391
        new.canon_taxonconcept_id = new.taxonconcept_id;
390
    IF new.canon_concept_id = 0 THEN -- make self-reference
391
        new.canon_concept_id = new.taxonconcept_id;
392 392
    END IF;
393 393
    RETURN new;
394 394
END;
......
1116 1116
    taxonconcept_id integer NOT NULL,
1117 1117
    creator_id integer NOT NULL,
1118 1118
    creationdate timestamp with time zone,
1119
    canon_taxonconcept_id integer,
1119
    canon_concept_id integer,
1120 1120
    parent_id integer,
1121 1121
    taxonname text,
1122 1122
    rank taxonrank,
......
1164 1164

  
1165 1165

  
1166 1166
--
1167
-- Name: COLUMN taxonconcept.canon_taxonconcept_id; Type: COMMENT; Schema: public; Owner: -
1167
-- Name: COLUMN taxonconcept.canon_concept_id; Type: COMMENT; Schema: public; Owner: -
1168 1168
--
1169 1169

  
1170
COMMENT ON COLUMN taxonconcept.canon_taxonconcept_id IS 'The taxonconcept containing the accepted synonym of this taxonconcept. taxonconcepts should be linked in a four-level hierarchy of datasource concept -> parsed concept -> matched concept -> accepted concept. A previously-accepted name''s concept should be further linked to the synonym that has replaced it.
1170
COMMENT ON COLUMN taxonconcept.canon_concept_id IS 'The taxonconcept containing the accepted synonym of this taxonconcept. taxonconcepts should be linked in a four-level hierarchy of datasource concept -> parsed concept -> matched concept -> accepted concept. A previously-accepted name''s concept should be further linked to the synonym that has replaced it.
1171 1171

  
1172 1172
To indicate a synonym between taxonconcepts of different sources, choose one taxonconcept to be authoritative and point the other taxonconcept to it using this field.
1173 1173

  
......
4653 4653

  
4654 4654

  
4655 4655
--
4656
-- Name: taxonconcept_canon_taxonconcept_id_self_ref; Type: TRIGGER; Schema: public; Owner: -
4656
-- Name: taxonconcept_canon_concept_id_self_ref; Type: TRIGGER; Schema: public; Owner: -
4657 4657
--
4658 4658

  
4659
CREATE TRIGGER taxonconcept_canon_taxonconcept_id_self_ref BEFORE INSERT OR UPDATE ON taxonconcept FOR EACH ROW EXECUTE PROCEDURE taxonconcept_canon_taxonconcept_id_self_ref();
4659
CREATE TRIGGER taxonconcept_canon_concept_id_self_ref BEFORE INSERT OR UPDATE ON taxonconcept FOR EACH ROW EXECUTE PROCEDURE taxonconcept_canon_concept_id_self_ref();
4660 4660

  
4661 4661

  
4662 4662
--
......
5459 5459

  
5460 5460

  
5461 5461
--
5462
-- Name: taxonconcept_canon_taxonconcept_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
5462
-- Name: taxonconcept_canon_concept_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
5463 5463
--
5464 5464

  
5465 5465
ALTER TABLE ONLY taxonconcept
5466
    ADD CONSTRAINT taxonconcept_canon_taxonconcept_id_fkey FOREIGN KEY (canon_taxonconcept_id) REFERENCES taxonconcept(taxonconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;
5466
    ADD CONSTRAINT taxonconcept_canon_concept_id_fkey FOREIGN KEY (canon_concept_id) REFERENCES taxonconcept(taxonconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;
5467 5467

  
5468 5468

  
5469 5469
--

Also available in: Unified diff