From: Date: April 1 2006 4:59pm Subject: getting table meta data (primary key, in this case) List-Archive: http://lists.mysql.com/internals/33492 Message-Id: <20060401145900.GK1596@w3.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="DN8g+DOX2TxGxleI" --DN8g+DOX2TxGxleI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable How can I, during query parsing on the server, efficiently find what field is labeled as a primary key for a given table? Why: SPARQL is a graph-based query language and doesn't (ideally) worry about how the links in the graph are constructed. The obvious mapping for the SPARQL query SELECT ?apt WHERE { ?d . ?d ?apt }; is SELECT Addresses_0.apt FROM Orders AS Orders_0 JOIN Addresses as Addresses_0 ON Orders_0.shippingAddress=3DAddresses_0.id WHERE Orders_0.id=3D3183; The missing piece of info is that the Orders.shippingAddress is a foreign key for Addresses.id . For simplicity on the first round, I'm assuming: 1 tuple identifiers are "primary keys" and are one field wide 2 tuple references are "foreign keys" and are one field wide 3 all tuple references to a table reference the same identifier Encountering ?d a second time in the query allows me to infer that Orders.shippingAddress is a foreign key to Addresses. I just need to pull "id" out of the air, or better yet, out of the table meta data. I have only seen this done when the client asks the question, which it does with a particular query. I'm hoping not to have to do a query while parsing, but will if I have to. I currently share no info between queries. (how do I do that, anyways?) For more info on this, see http://www.w3.org/2005/05/22-SPARQL-MySQL/ http://www.w3.org/2003/01/21-RDF-RDB-access/ --=20 -eric office: +81.466.49.1170 W3C, Keio Research Institute at SFC, Shonan Fujisawa Campus, Keio University, 5322 Endo, Fujisawa, Kanagawa 252-8520 JAPAN +1.617.258.5741 NE43-344, MIT, Cambridge, MA 02144 USA cell: +81.90.6533.3882 (eric@stripped) Feel free to forward this message to any list for any purpose other than email address distribution. --DN8g+DOX2TxGxleI Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iQEVAwUBRC6VNJZX2p1ccTnpAQIf8Af/dZ9S0F83CUeP2ynANP3Zr6vJOmvhQhXe MTFB9dSu/aQCGS+3dyJOnG3OvmPYY0t5Q+mxIGvvBda1ydlKpteQ1smc+uOeQ05d h3lb5r6m1b4c46oJwwp4wT2Gxt/mcGI6Tv24rWHvvyKg1gYSxpT3XlaB5WY20Ald L3ECHoPlYvtPXmEJDQdh910CZ7HKwkUskRfWbrThnmbhepQmkiee+/OcpyjuI6iX lcUUQF7YS0Ek6soJMJCmGiurzV4+X4IcuYA36huEIFrEOppIWWvKhxTHp4hIYwkA Pck4hd5u1Q/q/MP0w5B3dGc58h+FBWBXNeyjQ369zDLYDAU1ythpbg== =WofM -----END PGP SIGNATURE----- --DN8g+DOX2TxGxleI--