# Query using :Band returns zero rows for virtual graph tutorial

**URL:** <https://community.stardog.com/t/query-using-band-returns-zero-rows-for-virtual-graph-tutorial/3646>\
**Category:** Stardog Studio\
**Created:** [March 28, 2022, 12:47pm UTC](https://community.stardog.com/t/query-using-band-returns-zero-rows-for-virtual-graph-tutorial/3646 "2022-03-28T12:47:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![R3000](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/r3000/32/358_2.png) [@R3000](https://community.stardog.com/u/R3000)\
**Post date:** [March 28, 2022, 12:47pm UTC](https://community.stardog.com/t/query-using-band-returns-zero-rows-for-virtual-graph-tutorial/3646/1 "2022-03-28T12:47:11Z")

</div>

After following the steps in this tutorial [Using Virtual Graphs | Stardog Documentation Latest](https://docs.stardog.com/tutorials/using-virtual-graphs)  
the following query returns nothing. Why?

```auto
PREFIX : <http://stardog.com/tutorial/>
SELECT ?member ?name {
   GRAPH <virtual://music> {
      ?band a :Band ;
            :name "The Beatles" .
      ?member :member ?band ;
            :name ?name .
   }
}

```

I have used the correct files from github tutorials repo.

However this query return correct rows:

```auto
PREFIX : <http://stardog.com/tutorial/>
SELECT * 
FROM <virtual://music> {
      ?album a :Album ;
             :date ?date;
             :name ?name
} 

```

---

<div class="post-metadata">

**Author:** ![zachary.whitley](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/zachary.whitley/32/94_2.png) [@zachary.whitley](https://community.stardog.com/u/zachary.whitley)\
**Post date:** [March 28, 2022, 1:25pm UTC](https://community.stardog.com/t/query-using-band-returns-zero-rows-for-virtual-graph-tutorial/3646/2 "2022-03-28T13:25:45Z")

</div>

I'd take a look at the logs. Check that the default namespace is in there correctly (although the second query returning means that's probably not it. I see your'e including it in the query). Check that the data is actually in the source database. Make the query broader. Try just `?band a :Band` to see if there are any Band's in there and if that works try `?member :member ?band` to see if there are any members?

---

<div class="post-metadata">

**Author:** ![R3000](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/r3000/32/358_2.png) [@R3000](https://community.stardog.com/u/R3000)\
**Post date:** [March 28, 2022, 2:01pm UTC](https://community.stardog.com/t/query-using-band-returns-zero-rows-for-virtual-graph-tutorial/3646/3 "2022-03-28T14:01:19Z")

</div>

Zach,

Logs show nothing except when I get the query syntax wrong. Where do I check "the default namespace"?

This query returns one row:

```auto
PREFIX : <http://stardog.com/tutorial/>
SELECT * 
FROM <virtual://music> {
      ?band a :Band 
} 

```

![image](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/c/cd7eeed257365cacdd60819b31eab3d47128b3be.png)

This query returns rows:

```auto
PREFIX : <http://stardog.com/tutorial/>
SELECT * 
FROM <virtual://music> {
      ?band a :Band .
      ?member :member ?band 
} 

```

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/7/73de1a29c7dfa980436f93348bf6b7d3ac064a41.png)

Data in Artist table:  
 ![image](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/7/7ab7a5eb31bb0684aad22033bc054e92407d9d08.png)

Which should bring one row according to this mapping fragment, right?

```auto
:Artist{id} a :Band ;
            sm:map [sm:query "SELECT id FROM Artist WHERE type = 2"] .

```

---

<div class="post-metadata">

**Author:** ![zachary.whitley](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/zachary.whitley/32/94_2.png) [@zachary.whitley](https://community.stardog.com/u/zachary.whitley)\
**Post date:** [March 28, 2022, 2:12pm UTC](https://community.stardog.com/t/query-using-band-returns-zero-rows-for-virtual-graph-tutorial/3646/4 "2022-03-28T14:12:46Z")

</div>

You'd list the namespaces with `stardog namespace list <db-name>` but I don't _think_ that would be an issue. You're including the empty namespace in the query. Unless it's not overriding it for some reason. The tutorial included a line about setting the empty namespace so I wasn't sure if you did that or not.

Something certainly looks off. It's returning an artist where it should be returning a band. I'd double check the mapping file and the source database.

---

<div class="post-metadata">

**Author:** ![R3000](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/r3000/32/358_2.png) [@R3000](https://community.stardog.com/u/R3000)\
**Post date:** [March 28, 2022, 2:16pm UTC](https://community.stardog.com/t/query-using-band-returns-zero-rows-for-virtual-graph-tutorial/3646/5 "2022-03-28T14:16:02Z")

</div>

Zach,

How about both us try this tutorial in a clean new environment? Maybe with all the latest stardog changes somehow virtual graph tutorial is lagging?

Regards,  
Radu

---

<div class="post-metadata">

**Author:** ![zachary.whitley](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/zachary.whitley/32/94_2.png) [@zachary.whitley](https://community.stardog.com/u/zachary.whitley)\
**Post date:** [March 28, 2022, 2:31pm UTC](https://community.stardog.com/t/query-using-band-returns-zero-rows-for-virtual-graph-tutorial/3646/6 "2022-03-28T14:31:14Z")

</div>

I missed the section on the database. I'm not familiar with the tutorial so I guess there's a type field where an Artist is a band and from what you showed it's returning correctly. What would be missing is anything from another mapping that mapped all the regular bands. I'm guessing there's a Band table somewhere. There also seems to be a problem with the mapping from artist to band because The Beatles is only listing 4 members and there should be 5 unless it was the week George quit.

I'll see if I can find some time to run through the tutorial, give me a little bit though.

---

<div class="post-metadata">

**Author:** ![tim](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/tim/32/1177_2.png) [@tim](https://community.stardog.com/u/tim)\
**Post date:** [March 30, 2022, 2:06am UTC](https://community.stardog.com/t/query-using-band-returns-zero-rows-for-virtual-graph-tutorial/3646/7 "2022-03-30T02:06:23Z")

</div>

@R3000 can you try this query? I rewrote the query from the tutorial to select from the local named graph and the music named graph. The query pulls a mix of data that has been virtualized from the music database as well as the birthdate data that was inserted into Stardog. You could achieve a similar effect by selecting these 2 named graphs in Studio or turning on [Virtual Transparency](https://docs.stardog.com/virtual-graphs/virtual-transparency). In these 2 cases you would not need to specificy the named graphs in the query.

```auto
SELECT ?member ?name ?birthDate ?bandName
FROM NAMED <virtual://music> 
FROM NAMED <stardog:context:local>
{
  
      ?band a :Band ;
            :name ?bandName.
   ?member :birthDate ?birthDate;
           :member ?band;
           :name ?name
} 

```
