Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tutorial:poly_db_querying [2017/07/26 15:11] – paffenholz | tutorial:poly_db_querying [2018/02/10 11:38] (current) – deleted after merging into doku.php/tutorial/poly_db_tutorial oroehrig | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== Querying the Database ==== | ||
- | |||
- | There are three commands that can be used to query the database: | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | |||
- | === Queries === | ||
- | |||
- | Queries are given as perl hashes. In its most basic form a query has the form | ||
- | { " | ||
- | for example | ||
- | { " | ||
- | Note that the database is pretty strict with types, so strings always need to be quoted, while integers should not be. The following would fail: | ||
- | { " | ||
- | The empty query is allowed: | ||
- | {} | ||
- | returns all objects of a collection. You can query elements in an array with their index, e.g. | ||
- | { " | ||
- | gives polytopes with 12 edges (the entry at position one of the f-vector). | ||
- | |||
- | You can query ranges with '' | ||
- | { DIM => { ' | ||
- | to obtain polytopes of dimension less than 4. Observe the single quotation marks around '' | ||
- | { DIM => { ' | ||
- | to obtain those polytopes with dimensions between 4 and 10. | ||
- | |||
- | '' | ||
- | |||
- | === Obtain Objects that Satisfy a Query === | ||
- | |||
- | With '' | ||
- | { $a=db_query({' | ||
- | which returns all three dimensional smooth reflexive polytopes. The first argument (the query) can be any query as in the previous section. | ||
- | |||
- | The name of the database and the collection can be stored in custom variables: | ||
- | |||
- | | ||
- | | ||
- | |||
- | We assume this in the following. If you want to make this persistent over the next polymake sessions then add '' | ||
- | { $a=db_query({' | ||
- | |||
- | If you just want to have one (random) object that satisfies your query, then you can add '' | ||
- | { $a=db_query({' | ||
- | |||
- | If you want, for a given property, the set of values that can be attained for this property, then you can use the option '' | ||
- | { $a=db_query({' | ||
- | returns an array that contains all values '' | ||
- | |||
- | === Count Objects that Satisfy a Query === | ||
- | |||
- | === Obtain Object '' | ||
- | |||
- | |||
- | |||