In this practical you will use the P/FDM Query Generator for Windows, which can be downloaded from the University of Aberdeen.
The most recent version of the Visual Navigator is available.
The Visual Navigator was initially described in:
FILES USED ========== 0) You need a schema file in Daplex Syntax - see unidb_schema.sch for example. You need a copy of it terminated by ";" for Prolog parser, see unidb.sch.txt To see queries running you need a load file for data in a temporary module, see unidb_loa.txt for example. You can just use the unidb example by typing the stem "unidb" into Vis Nav window. Other datsets are "ab" (no load file). Alternatively use files of your own : xxx_schema.sch, xxx.sch.txt, xxx_loa.txt 1) double click on batch file RunJPFDM.bat in top level dir. Otherwise use "run" command on Start menu to execute commands in batch file. 2) JPFDM Query window should appear: LOADING SCHEMAS and SAMPLE DATA =============================== 2.1) type stem -- e.g. unidb -- into textarea for "Schema Name" 2.2) CLICK ONCE on "Load Schema" button to call up P/FDM through Sicstus Jasper(TM) interface. In the Output window you should see a message confirming schema is loaded and DONE. 2.3) To START the Visual Navigator QUERY GENERATOR, CLICK ONCE only on the JPFDM icon button. If you click twice you get two GUI BUILDER windows (look at task bar) - close one of them. 3) Wait for Window with ER schema diagram to appear. You may need to drag bottom half of window down to get query window to show, with Accept and Submit buttons. Initially it just says "Print()" You can move ellipses representing entities around by clicking to release Lock in Edit menu off top menubar, then left click and drag. Relships (labelled arcs) will follow. When finished click on Lock again to avoid accidentally dragging. You can save position of these for future use by clicking File > Print Placement {currently these positions have to be hand edited on end of _schema.sch file} 4) Steps to GENERATE QUERY ============= A) Right at the start you need Left click to select an ellipse (perimeter goes red). There is a brief delay before the ellipse turns red. A tentative "for each" to iterate over this class appears at foot. To add this "for each" to query, click Right button, which also turns ellipse grey-blue. {If right button wont work to copy the bottom line of the screen into the query, try the Accept button at bottom of schema diagram.} B) You can now add selected attributes of this entity to the list to be printed. Just left double click the entity and a small menu box should appear. Left click to highlight selected attribs in the order you want to print them. At any time in future you can select entity circle again (if not already red boundary) and double click to bring up menu then, click on attrib to unhighlight and remove from print list. (If added again it goes at end of list.) C) Relationships(associations) connected to current entity ellipse are shown grey-blue. Click in order to select and thus navigate to next entity. Once more, tentative "for each" appears at foot. Confirm by right click to add to query. Ellipse beyond goes grey-blue and becomes the new focus of attention. Thus you build up the query by following a path, alternatively clicking on entity Ellipses and relationship Circles. You can also double click on "for each" in Query window which will highlight corresponding ellipse in diagram. D) To delete last "for each" part of query, click the "for each" string (turns red) and then press DEL key. This also works to delete last "such that" condition in any query line. (If delete button won't work then try clicking on text in very bottom line, regardless of contents, and press delete again. Likewise if it wont respond to double click on part of an expression.) E) To add a "such that" condition to a "for each" which is highlighted, left click on Add Modifier. This adds an empty rectangle at end of line following "such that" . Double click on this turns it red and brings up the Expression Editor Window. You start usually with "Select Function" button on LEFT of expression. After choosing an entity type and attrib and confirming by OK, you must choose "Constant" or "Select Function" on the RIGHT, to select something to compare it with. If a Constant, key in an integer or string (NO Quotes) else Select Function on RIGHT. Only then can you alter the Comparison op in middle! Note the button labelled "Select Function" also works to select a variable name (eg i0) by itself, if you dont click on a function name in the menu. This is necessary for e.g. i0 <> i1, abspos(c1,i2) The same expression editor box works to fill in a single parameter value for a function call - e.g. a Constant or entity variable name or attribute name. Here you only fill in the LEFT. RUNNING QUERIES =============== F) To run a query against loaded data in a temporary in-memory database: click on Submit button. The Visual Navigator is iconified and the generated query written to "jpfdmquery.txt". Bring the main GUI window back to front. Provided you previously pressed "Load Schema", you can now press "Run Daplex Query" to run this query. G) Query results come back in a file "jpfdmres.txt" which is displayed as a JTable on screen. If generated by Vis Navigator, the column headings are set automatically. To expand column headings database, move arrow cursor slowly along header to right until it turns into black vertical cursor on edge of col. header. Now press mouse button and drag to right to expand (or left to shrink). H) A quick and elegant way to add modifications to a query is to highlight field values in a row or column. Use Shift key to highlight non-adjacent fields as usual. If you then press the Copy button at head of JTable, these can be used to genera te selections. Resume Entity Editor off taskbar. Now press "Paste" button! See how query is modified! Selections in same row are "AND"-ed, those in same column are "OR"-ed! See paper in UIDIS'99 Edinburgh procs (IEEE Comp. Soc). G) To finish off, close the main application window, or else select Quit from File menu of Visual Navigator which shuts all windows. CAPTURING CONSTRAINTS - EXPERIMENTAL FEATURE ============================================= There is an extra window that shows constraints enforced on the test data. The P/FDM Hypertext Manual explains the syntax of these domain-specific constraints, which are quantified formulae of First Order Logic (FOL) expressed against the displayed E-R model. To see where any loaded data did not satisfy constraints (and was not loaded), scroll back through the DOS command window. The faulty data is also written to a REPAIR file. If you have composed a query, you can turn it into a constraint as follows: 1) click once on "Check Insist Constrt". This adds an extra line: insist [ ] to the query. In the box following "insist" you can now add an expression that you wish to be invariant, for all values of variables permitted by "such that" in the query. Double click this box to bring up the usual Expression editor (see above). You can form an equality or inequality comparison, for example: for each p0 in project insist duration(p0) > 5 In FOL this reads: (For all p) p isin project implies duration(p) >5 You can use the "Add Modifier" button to "and" in extra conditions after insist, provided the "insist" is highlighted in red. {click on insist, if not} 2) You can instead capture an Existential Constraint by using the exist constrt button: The exist constraint refers to an object accessed via a Relationship arc on the diagram. We can ask the GUI to generate a query that checks that at least one such object exists for each instance of the related object...], subject to such t hat clauses. For example: for each t0 in teacher [such that ...] insist exist p1 in project such that [condition] [and condition ...] In this example you start by clicking on the teacher ellipse, and selecting attr ibutes to print for instances where the constraint fails. Next you click on the relationship symbol on the arc leading to "project". This goes red, but INSTEAD of confirming it via the "accept" button, you press the "check exist" button nearby. This creates an extra line with an insist exist followed by a condition box which you can fill in by clicking, just as for the basic insist constraint. NOTE - once you have created an insist constraint of either variety, DON'T press the insist buttons again! Just press "Add Modifier" button if you want to add extra conditions, or DEL if you want to delete highlighted conditions. CHECKING CONSTRAINTS ==================== 3) You can check a constraint, as for a query, by pressing the Submit button. On pressing "Run Daplex Query", the JTable of results now represents Exceptions to the constraint! If there are NO exceptions -- a blank table -- you can hang on to the constraint by pressing the "Write Constr." button above the JTable. When you close this window you then see the new constraint in a window that shows constraints already enforced on the data. You can now continue forming other constraints or asking queries. TO COME - RDFS form of constraint. IRRITATING MINOR BUGS 1) If you want to see attributes of an entity(ellipse) you need to highlight it. Double click on the "for each" line that refers to it, or else click on a grey-blue path that leads to it. 2) If you interchange two columns in the response table and then highlight values for Drag and Drop, it uses the name and value from the column originally in that position. 3) If you delete selection conditions that have been dragged and dropped then it puts in an unwanted "or" at the front when dragging and dropping replacement ones - better to delete the whole line by clicking on "for each" then DELete key and then regenerate it. 4) There's no easy way to print the contents of a response window, and/or the text of the query under it. 5) If you double click on Add Modifier, it puts in extra selection boxes which aren't needed. Highlight them and Delete before proceeding.