user1355603
user1355603

Reputation: 305

what does cardinality mean in SPARQL?

Cardinality of the results of a query is usually mentioned when studying papers related to SPARQL, rdf, etc...however, I am unable to understand what does cardinality here really means. I am a novice to SPARQL and rdf so can somebody be kind enough to explain what does cardinality means in SPARQL and rdf.

Cardinality in databases refers to uniqueness of values, what w.r.t to SPARQL and the results of its query does cardinality mean...I am really confused. Somebody please explain.

As it refers to unique values then what does maximum Cardinality and minimum Cardinality mean?

Upvotes: 2

Views: 621

Answers (1)

Alfredo Serafini
Alfredo Serafini

Reputation: 194

SPARQL is constructed to have some naive similitude with SQL, but here there are no tuples, but triples. Every triple is in the form SPO subject-predicate-object (someone says the P is for property), and you could have some concrete extended model that make use of combination of those indices and a fourth indice for the context. Pratically speaking (just to re-use the naive idea i said before) you could imagine a huge table with a tuple for every triple. So the Cardinality of the DISTINCT triples here represents the cardinality of the "facts" regarding a single subject. You should see then there is a tatally different model from the relational one. For example a person with a first name and a surname via rdf/foaf would be something like (using turtle syntax):

@prefix foaf:    <http://xmlns.com/foaf/0.1/> .

_:X  foaf:name   "John" .
_:X  foaf:surname   "Doe" 

.

and here we have two triples.

So a SPARQL query like:
SELECT COUNT(?S) as ?triples
WHERE{
?S ?P ?O.
?S foaf:name ?name.
}

would give simply triples = 2, as there are 2 triples involved in relations for the subject.

Sorry for the oversimplification, but hope it helps to start :-) Alfredo

Upvotes: 1

Related Questions