Question

... Yeah, yeah, I know traditional joins don't exist. I actually like the freebase query methodology in theory, just having a little trouble getting it to actually work for me : )

Anyone have a dumb-simple example of getting Freebase data via MQL that pulls from two different "tables"? In particular, I'm trying to get automotive data... so for example, pulling fields from both /automotive/model_year and /automotive/trim_level.

I've read the documentation (for hours actually). There's a distinct possibility that I'm looking right at such an example somewhere and just not seeing it because my OLTP brain just doesn't comprehend what it's seeing.

* Note * ... that the two "types" I'm working with above are siblings, not parent/child. Does freebase even allow joining data between sibling nodes... I see examples of queries pulling from parent/child, but not from siblings I don't think (or I've overlooked them).

Was it helpful?

Solution

Basically, could you not just restrict the queries according to the user's input?

When the user selects the year, you get all makes that have a matching model year:

[{
  "model_s": [{
    "model_years": [{
      "year": [{
        "type":    "/type/datetime",
        "value<":  "2010", // User input
        "value>=": "2009" // User input
      }],
      "type": "/automotive/model_year"
    }],
    "type": "/automotive/model"
  }],
  "id":   null,
  "name": null,
  "type": "/automotive/make"
}]​

If the make is selected and you need the models for that make and year:

[{
  "model_years": [{
    "year": [{
      "type":    "/type/datetime",
      "value<":  "2010", // User input from above
      "value>=": "2009" // User input from above
    }],
    "type": "/automotive/model_year"
  }],
  "id":   null,
  "name": null,
  "type": "/automotive/model",
  "make": [{
    "id":   "/en/volkswagen", // User input
    "type": "/automotive/make"
  }]
}]​

Or did I just not understand your problem correctly?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top