Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

loc-id-auth-index.sql 1.5 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  1. --- #step Create auth labels
  2. CREATE TABLE IF NOT EXISTS locid.auth_node_label (
  3. subject_id UUID NOT NULL,
  4. label VARCHAR NOT NULL
  5. );
  6. INSERT INTO locid.auth_node_label
  7. SELECT DISTINCT subject_id, lit_value
  8. FROM locid.auth_triple
  9. JOIN locid.node_aliases pa ON (pred_id = pa.node_id)
  10. JOIN locid.literals ON (object_id = lit_id)
  11. WHERE node_alias IN ('label', 'auth-label');
  12. CREATE INDEX IF NOT EXISTS auth_node_label_subj_idx
  13. ON locid.auth_node_label (subject_id);
  14. CREATE INDEX IF NOT EXISTS auth_node_label_lbl_idx
  15. ON locid.auth_node_label (label);
  16. ANALYZE locid.auth_node_label;
  17. --- #step Summarize gender data
  18. CREATE MATERIALIZED VIEW locid.mads_gender_summary AS
  19. SELECT COUNT(t.subject_id), o.node_id, o.node_iri, l.label
  20. FROM locid.auth_triple t
  21. JOIN locid.node_aliases pa ON (pred_id = pa.node_id)
  22. JOIN locid.nodes o ON (object_id = o.node_id)
  23. LEFT JOIN locid.auth_node_label l ON (object_id = l.subject_id)
  24. WHERE pa.node_alias = 'gender'
  25. GROUP BY o.node_id, o.node_iri, l.label
  26. ORDER BY COUNT(t.subject_id) DESC;
  27. CREATE MATERIALIZED VIEW locid.skos_gender AS
  28. SELECT nt.object_id AS node_id, l.label
  29. FROM
  30. -- author triple
  31. locid.auth_triple nt
  32. -- author object to exclude
  33. LEFT JOIN locid.nodes ton ON (nt.object_id = ton.node_id)
  34. --- node type triples
  35. JOIN locid.auth_triple tt ON (nt.object_id = tt.subject_id)
  36. --- node labels
  37. JOIN locid.auth_node_label l ON (l.subject_id = nt.object_id)
  38. WHERE
  39. nt.pred_id = locid.common_node('gender')
  40. AND ton.node_id IS NULL
  41. AND tt.pred_id = locid.common_node('type')
  42. AND tt.object_id = locid.common_node('concept');
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...