Morten, app-schema uses the underlying GeoServer simple feature implementation, which assumes a single table/view for each feature type. Your many-to-many relationship table is known as a link table (amongst other names): http://en.wikipedia.org/wiki/Link_table This is a good pattern because your database is normalised.
To use your tables in GeoServer, you need to present your data to GeoServer as a single relation. For example, you can create a view SFE_JST that joins SFE with the link table to present GeoServer with a relation that is denormalised (multivalued in SFE_ID) to represent the multivalued foreign key. Note that this view must be sorted by SFE_ID so that the multivalued properties are collected correctly (very important): http://docs.geoserver.org/latest/en/user/data/app-schema/mapping-file.html#denormalised-sources You should now be able to create a feature from the SFE_JST view and use app-schema feature chaining to nest it inside a feature created from JST (using a multivalued FEATURE_LINK in the SFE_JST feature type, perhaps?). See my thumbnail sketch below. Note that you will have to add spatial metadata for your view. Kind regards, Ben. ------------------- CREATE TABLE jst ( jst_id INTEGER PRIMARY KEY, name VARCHAR(10) ); CREATE TABLE sfe ( sfe_id INTEGER PRIMARY KEY, colour VARCHAR(10) ); CREATE TABLE jst_x_sfe ( jxs_jst_id INTEGER REFERENCES jst (jst_id), jxs_sfe_id INTEGER REFERENCES sfe (sfe_id) ); INSERT INTO jst VALUES (1, 'one'); INSERT INTO jst VALUES (2, 'two'); INSERT INTO jst VALUES (3, 'three'); INSERT INTO sfe VALUES (11, 'red'); INSERT INTO sfe VALUES (22, 'green'); INSERT INTO sfe VALUES (33, 'blue'); INSERT INTO jst_x_sfe VALUES (1, 11); INSERT INTO jst_x_sfe VALUES (1, 22); INSERT INTO jst_x_sfe VALUES (2, 22); INSERT INTO jst_x_sfe VALUES (2, 33); INSERT INTO jst_x_sfe VALUES (3, 33); INSERT INTO jst_x_sfe VALUES (3, 11); CREATE VIEW sft_jst AS SELECT sfe_id, colour, jxs_jst_id jst_id FROM sfe INNER JOIN jst_x_sfe ON sfe.sfe_id = jst_x_sfe.jxs_sfe_id ORDER BY sfe_id; SELECT * FROM sft_jst; ----------------- On 10/01/11 22:00, Lindegaard, Morten wrote: > Hi, > > I'm trying to configure GeoServer 2.1-beta3 and the app-schema extension. > > To keep it simple, I have three database tables: JST, JST_X_SFE, and SFE. > > JST contains data and has a field JST_ID with an identifier. > SFE contains data and has a field SFE_ID with an identifier. > JST_X_SFE has two fields, JXS_JST_ID and JXS_SFE_ID, that relate records in > JST with records in SFE by means of JST_ID and SFE_ID. The relation is > many-to-many. > > The GML response from the WFS should comply with an existing XML schema. > > Data in SFE corresponds to a feature type. > Data in JST corresponds to a feature type in which the SFE-featuretype is > nested. > The table JST_X_SFE does not correspond to a feature type, and I run into > problems when I try to link or refer to it. > > I've tried to follow the user manual, but I haven't managed to configure the > nesting of the feature type. However, I'm new to GeoServer and app-schema, so > I can easily have overlooked some details. > > I would like to ask, if anybody has experience with using app-schema with a > similar database layout, i.e. with a table that contains the relation between > a "containing" feature type and a nested feature type. > > > Kind regards, > > Morten Lindegaard > > > -- Ben Caradoc-Davies <[email protected]> Software Engineering Team Leader CSIRO Earth Science and Resource Engineering Australian Resources Research Centre ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ Geoserver-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geoserver-users
