Search code examples
mysqlmarklogictriples

How to create Triples from MySql


I have used the d2rq utility to create .ttl files and then have imported it in MarkLofgic but unable to get the desired results.

Moreover my data looks like this.Triples generated by d2rq

How can I create Triples from MySql Data to be used for Querying in SPARQL in MarkLogic. SOmeone suggested that I should Consider Primary key values as subject, column names as Predicates & cell values as objects to convert into triples, but How ? Thanks & Regards Swapneel GOLAPKAR


Solution

  • What you are showing there, are triples in the format that MarkLogic stores them in the database. Make sure to enable the triple index from Admin ui for that database to be able to use SPARQL on them.

    Once enabled you can run commands like count(cts:triples()) from QConsole to see how many triples have been loaded, and run SPARQL from there as well.

    You can also connect to the /v1/graphs/sparql REST endpoint.

    Regarding how data should look as triples, given two sample records like below (expressed as XML for convenience):

    <Drug_Dtl>
        <Drug_ID>D001</Drug_ID>
        <Drug_name>Glyburide 5 mg</Drug_name>
        <Brand_name>Diabeta</Brand_name>
        <Brand>Novo Nordisk</Brand>
        <strength>5 mg</strength>
        <NoOfPills>1</NoOfPills>
        <TotalDailyDose>5 mg</TotalDailyDose>
        <Cost>$51</Cost>
        <DailyPills>1</DailyPills>
    </Drug_Dtl>
    
    <Prescriber>
        <PrescriberId>PSC001</PrescriberId>
        <PrescriberName>Wa&#x200C;&#x200B;yne</PrescriberName>
        <Prescriber_Address>7 Elgar Center</Prescriber_Address>
        <City>Chicago</City>
        <State>Illinois</State>
    </Prescriber>
    

    I would expect triples similar to (expressed as turtle for convenience):

    <D001> <Drug_name> "Glyburide 5 mg".
    <D001> <Brand_name> "Diabeta".
    <D001> <Brand> "Novo Nordisk".
    <D001> <strength> "5 mg".
    <D001> <NoOfPills> "1".
    <D001> <TotalDailyDose> "5 mg".
    <D001> <Cost> "$51".
    <D001> <DailyPills> "1".
    
    <PSC001> <PrescriberName> "Wa&#x200C;&#x200B;yne".
    <PSC001> <Prescriber_Address> "7 Elgar Center".
    <PSC001> <City> "Chicago".
    <PSC001> <State> "Illinois".
    

    HTH!