CREATE DATA_SOURCE go
(
	fullname	'gene ontology',
	reference	'http://www.geneontology.org',
	description	'gene ontology is a controlled vocabulary ...'
);

CREATE GRAPH go_graph
(
	version		STRING VALUE 'go-11-2004',
	... other meta-data ...
) SOURCE go;

IMPORT NODE FROM term
(
	id		AS ATTRIBUTE,
	name		AS ATTRIBUTE,
	term_type	AS ATTRIBUTE,
	definition	AS ATTRIBUTE
 ) GRAPH go_graph	// indirectly, it suggests that this term is from source GO.
PRIMARY IDENTIFIER (id, name);
// primary identifier is used to compare two nodes which may be from different sources.
// In this example, if two nodes have the same id and name, then merge them.

// store species as a separate table.
// skip field 'lineage'. Rename 'genus' to 'genus_name'.
IMPORT TABLE go_species FROM species (id, genus AS genus_name, species);

// if we want to import table 'species' as it is, just say:
// IMPORT TABLE FORM species;

IMPORT NODE FROM gene_product
(
	id		AS ATTRIBUTE,
	name		AS ATTRIBUTE entity_name,
// rename the property name. It is especially useful during node merge.
// for example, genes from MIPS have a property called  'orf', and genes from
// SGD has a property called 'orfname'. Both 'orf' and 'orfname' refer to the open
// reading frame name of a yeast gene. By renaming 'orfname' to 'orf', it indicates
// that the mapping tool should merge these two fields.
species_id	AS ATTRIBUTE REFERENCES go_species (id)
// this reference association will be stored in system catalog.
) GRAPH go_graph
  PRIMARY IDENITIFER (name);

// The edge still means traditional edge. Internally it will be split and stored as
// connectorNode and two links.
IMPORT EDGE FROM term2term
(
term1_id	AS SOURCE REFERENCE,
term2_id	AS TARGET REFERENCE,
label		AS ATTRIBUTE relationship    // edge attribute
) DIRECTION directed
  GRAPH go_graph;
// Here, REFERENCE suggests to follow the foreign key specified in the relational
// schema to identify the node in term table.

// edge table
IMPORT EDGE FROM term2GeneProduct
(
	term1_id	AS SOURCE REFERENCE,
	gene_product_id AS SOURCE REFERENCE
) DIRECTION directed
  GRAPH go_graph;

// simple one-to-many property.
IMPORT NODE ATTRIBUTE FROM gene_product_synonyms
(
	gene_product_id	AS NODE REFERENCE,  // node identifier
	synonym		AS ATTRIBUTE
) GRAPH go_graph;

// properties are already in name-value pair.
IMPORT NODE ATTRIBUTE FROM gene_product_properties
(
	gene_product_id	AS NODE REFERENCE,
	property_name	AS ATTRIBUTE KEY,
	property_value	AS ATTRIBUTE VALUE
) GRAPH go_graph;

// hypernode for complex type of data.
IMPORT HYPERNODE FROM gene_product_family
(
	gene_product_family_name	AS ATTRIBUTE,
	gene_product_id		AS MEMBER NODE REFERENCE,
	putative			AS MEMBER ATTRIBUTE
	// internally, 'putative' becomes a property of 'member-of' edge.
) GRAPH go_graph
PRIMARY IDENTIFIER (gene_product_family_name);