80 likes | 212 Views
Oracle RDF Scientific American Example. The following is just for Dr. Cannata to do CREATE TABLESPACE rdf_tblspace DATAFILE 'C:APPADMINISTRATORORADATAORCLdf_tblspace.dat' SIZE 1024M REUSE AUTOEXTEND ON NEXT 256M MAXSIZE UNLIMITED SEGMENT SPACE MANAGEMENT AUTO;
E N D
Oracle RDF Scientific American Example The following is just for Dr. Cannata to do CREATE TABLESPACE rdf_tblspace DATAFILE 'C:\APP\ADMINISTRATOR\ORADATA\ORCL\rdf_tblspace.dat' SIZE 1024M REUSE AUTOEXTEND ON NEXT 256M MAXSIZE UNLIMITED SEGMENT SPACE MANAGEMENT AUTO; EXECUTE SEM_APIS.CREATE_SEM_NETWORK ('rdf_tblspace');
_____________________________________________________ Only do this if you’re starting over. DROP TABLE Cannata_rdf_data cascade constraints ; DROP SEQUENCE triple_number ; DROP TRIGGER "PHIL"."TRIPLE_NUMBER_TRIGGER“ EXECUTE SDO_RDF.DROP_RDF_MODEL('Cannata_model') ; EXECUTE SDO_RDF_INFERENCE.DROP_RULEBASE('Cannata_rb') ; _____________________________________________________ Start Here. CREATE TABLE Cannata_rdf_data (id NUMBER, triple SDO_RDF_TRIPLE_S) ; CREATE SEQUENCE triple_number start with 1 increment by 1 nomaxvalue; CREATE TRIGGER triple_number_trigger before insert on Cannata_rdf_data for each row begin select triple_number.nextval into :new.id from dual; end; / EXECUTE sdo_rdf.create_rdf_model('Cannata_model', 'Cannata_rdf_data', 'triple') ; EXECUTE SDO_RDF_INFERENCE.CREATE_RULEBASE(‘Cannata_rb') ;
create or replace function strreplace(str varchar2, from_str varchar2, to_str varchar2) return varchar2 AS str_temp varchar2(4000); str_pos number := instr(str, from_str); BEGIN str_temp := str; while ( str_pos > 0 ) loop str_temp := substr(str_temp, 0, str_pos-1) || to_str || substr(str_temp, str_pos + length(from_str)); str_pos := instr(str_temp, from_str); end loop; return str_temp; END;
Insert Data – click link to see data 20 Scientific American.sql
SELECT strreplace(x, 'sa:', '') "C" FROM TABLE(SDO_RDF_MATCH( ' (?x :MEANS :NYC) ', SDO_RDF_Models('cs347_49_model'), SDO_RDF_Rulebases ('RDFS', 'cs347_49_RB'), SDO_RDF_Aliases (SDO_RDF_Alias('', 'sa:')), null)) SELECT strreplace(z, 'sa:', '') "A", strreplace(y, 'sa:', '') "B", strreplace(x, 'sa:', '') "C" FROM TABLE(SDO_RDF_MATCH( ' (?x :MEANS :NYC)(?y :MEANS :SetIn)(?z :MEANS :Sitcoms)(?z ?y ?x) ', SDO_RDF_Models('cs347_49_model'), SDO_RDF_Rulebases ('RDFS', 'cs347_49_RB'), SDO_RDF_Aliases (SDO_RDF_Alias('', 'sa:')), null))