Query properties in an one to many relation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Query properties in an one to many relation

planetenxin
Hi Forum,

i've the following initial situation:

A page Person:

[[Name::{{{Name}}}]]
[[First_Name::{{{First_Name}}}]]
[[Name::{{{Name}}}]]
[[E-Mail::{{{E-Mail}}}]]

[[Category:Person]]


A Page Telephone:

[[International Country Code::{{{International Country Code}}}]]
[[Area Code::{{{Area Code}}}]]
[[Local Number::{{{Local Number}}}]]
[[Person::Belongs To Person::{{{Belongs To Person}}}]]
[[Phone Type::{{{Phone Type}}}]]

[[Category:Telephone]]


A Telephone number belongs to max. one person. That reference is stored in the [[Belongs To Person]] property as suggested here: http://www.mediawiki.org/wiki/Extension:Semantic_Forms#Data_design_issues.

What i'd like to get is a table of persons with e.g. a certain area code, as follows:

First Name |Name  | E-Mail                        | Local Number
-------------------------------------------------------
Hans         | Meier |hans.meier@sample.com | 12345
...

I built the following query:

{{#ask: [[Category:Telephone]][[Area Code::89]]
| mainlabel=-
| ? First Name
| ? Name
| ? E-Mail
| ? Local Number
}}

The problem: First Name, Name, E-Mail could not be "resolved". Only the Local Number is shown, all other cells are empty.
Any idea, how that could be done?
Reply | Threaded
Open this post in threaded view
|

Re: Query properties in an one to many relation

S Page-2
planetenxin wrote:

> A Telephone number belongs to max. one person. That reference is stored in
> the [[Belongs To Person]] property as suggested here:
> http://www.mediawiki.org/wiki/Extension:Semantic_Forms#Data_design_issues.
>
> What i'd like to get is a table of persons with e.g. a certain area code, as
> follows:
> ...
>
> I built the following query:
>
> {{#ask: [[Category:Telephone]][[Area Code::89]]
> | mainlabel=-
> | ? First Name
> | ? Name
> | ? E-Mail
> | ? Local Number
> }}
>
> The problem: First Name, Name, E-Mail could not be "resolved". Only the
> Local Number is shown, all other cells are empty.

 From http://semantic-mediawiki.org/wiki/Help:Semantic_search
"Semantic queries specify two things:
    1. Which pages to select
    2. What information to display about those pages "

Your query selects some telephone pages, but most of the info you want
to display is not about those pages.  A Telephone doesn't have a First_Name!

To show First_Name, you need to select some Person pages and display
their information.

> Any idea, how that could be done?

a) Implement an inverse [[Has telephone]] property, so you can query for
Persons with a telephone page, and show other information about the
people.  The s-mw.org site shows ways to keep a property and its inverse
in sync, see the California and Germany pages.

You don't say what your Telephone page is named.  If displaying the name
of the Telephone page in a Person query isn't good enough, you're back
to the same problem of trying to display information from two related
pages in one query.


b) Hack your Telephone query to display information about the people.
Your query for phone number returns Belongs_to_person, then "somehow"
you turn around and query to get information about the person.

i) You can make a query that returns a list of people and a phone param
that you then manually edit or execute to be a query for person information.
ii) Maybe you fabricate a Telephone query results template into which
you pass a person and it uses #show to display information about them.

I tried ii) at
<http://sandbox.semantic-mediawiki.org/wiki/Test_query#Getting_information_about_object_pages>
, it didn't work!


c) You say "Telephone number belongs to max. one person".  So maybe you
could create subpages named John_Doe/Main_phone and John_Doe/Cell_phone
, and simply transclude or query those to provide the phone information.
  I'm trying this approach myself and running into problems using a page
name returned by a query to call another page name, and in general SMW
is not aware of subpage relationships.


SMW is a powerful way to annotate and browse wiki pages, but it's not a
reporting tool that lets you slice and reassemble information from
multiple pages.

--
=S

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user