northwind.cphrase

Here you can browse the full northwind.cphrase file. This is an example of integrating C-Phrase with a remote database.

<?xml version="1.0" encoding="UTF-8"?>
<config id="northwind" db="postgresql:dbname=northwind host=44.202.44.37 user=readonly password=db123 port=5432" language="english" version="1.0.0411" description="">

    <table id="categories" lex="customer,customers">
        <column id="categoryid" type="int" notnull="true"/>
        <column id="categoryname" type="text"/>
        <column id="description" type="text"/>
        <primary_key key="categoryid"/>
    </table>

    <table id="customers">
        <column id="customerid" type="text" notnull="true"/>
        <column id="companyname" type="text"/>
        <column id="contactname" type="text"/>
        <column id="contacttitle" type="text"/>
        <column id="address" type="text"/>
        <column id="city" type="text"/>
        <column id="region" type="text"/>
        <column id="postalcode" type="text"/>
        <column id="country" type="text"/>
        <column id="phone" type="text"/>
        <column id="fax" type="text"/>
        <primary_key key="customerid"/>
    </table>

    <table id="employees" lex="employee,employees,work,workers">
        <column id="titleofcourtesy" type="text"/>
        <virtual_column id="name" type="text"><![CDATA[
$VAR.firstname || ' ' || $VAR.lastname]]>
        </virtual_column>
        <column id="employeeid" type="int" notnull="true" properties="-project"/>
        <column id="lastname" type="text" properties="-project"/>
        <column id="firstname" type="text" properties="-project"/>
        <column id="title" type="text"/>
        <column id="reportsto" type="int"/>
        <column id="birthdate" type="date"/>
        <column id="hiredate" type="date"/>
        <column id="address" type="text"/>
        <column id="city" type="text"/>
        <column id="region" type="text"/>
        <column id="postalcode" type="text"/>
        <column id="country" type="text"/>
        <column id="homephone" type="text"/>
        <column id="notes" type="memo"/>
        <primary_key key="employeeid"/>
        <foreign_key from="reportsto" to="employees" lex="reports to,supervises"/>
        <primary_value key="name"/>
    </table>

    <table id="orderdetails" silent="true">
        <column id="orderid" type="int" notnull="true"/>
        <column id="productid" type="int" notnull="true"/>
        <column id="unitprice" type="int"/>
        <column id="quantity" type="int"/>
        <column id="discount" type="real"/>
        <primary_key key="orderid,productid"/>
        <foreign_key from="orderid" to="orders"/>
        <foreign_key from="productid" to="products"/>
    </table>

    <table id="orders">
        <column id="orderid" type="int" notnull="true"/>
        <column id="customerid" type="text"/>
        <column id="employeeid" type="int"/>
        <column id="orderdate" type="date"/>
        <column id="requireddate" type="date"/>
        <column id="shippeddate" type="date"/>
        <column id="shipvia" type="int"/>
        <column id="freight" type="int"/>
        <column id="shipname" type="text"/>
        <column id="shipaddress" type="text"/>
        <column id="shipcity" type="text"/>
        <column id="shipregion" type="text"/>
        <column id="shippostalcode" type="text"/>
        <column id="shipcountry" type="text"/>
        <primary_key key="orderid"/>
        <foreign_key from="customerid" to="customers"/>
        <foreign_key from="employeeid" to="employees"/>
        <foreign_key from="shipvia" to="shippers"/>
    </table>

    <table id="products">
        <column id="productid" type="int" notnull="true"/>
        <column id="productname" type="text"/>
        <column id="supplierid" type="int"/>
        <virtual_column id="category" type="text" properties="+value-stands-for-table"><![CDATA[
(SELECT Z.categoryname FROM categories AS Z WHERE $VAR.categoryid = Z.categoryid)
]]>
        </virtual_column>
        <column id="categoryid" type="int"/>
        <column id="quantityperunit" type="text"/>
        <column id="unitprice" type="int"/>
        <column id="unitsinstock" type="int"/>
        <column id="unitsonorder" type="int"/>
        <column id="reorderlevel" type="int"/>
        <column id="discontinued" type="text"/>
        <primary_key key="productid"/>
        <foreign_key from="supplierid" to="suppliers"/>
        <foreign_key from="categoryid" to="categories"/>
    </table>

    <table id="shippers">
        <column id="shipperid" type="int" notnull="true"/>
        <column id="companyname" type="text"/>
        <column id="phone" type="text"/>
        <primary_key key="shipperid"/>
    </table>

    <table id="suppliers">
        <column id="supplierid" type="int" notnull="true"/>
        <column id="companyname" type="text"/>
        <column id="contactname" type="text"/>
        <column id="contacttitle" type="text"/>
        <column id="address" type="text"/>
        <column id="city" type="text"/>
        <column id="region" type="text"/>
        <column id="postalcode" type="text"/>
        <column id="country" type="text"/>
        <column id="phone" type="text"/>
        <column id="fax" type="text"/>
        <column id="homepage" type="text"/>
        <primary_key key="supplierid"/>
    </table>

    <view id="bought_categories" lex="buying record,buying records,bought,were bought by" explore="false">
        <column id="customerid" type="text"/>
        <column id="categoryid" type="int"/>
        <foreign_key from="customerid" to="customers"/>
        <foreign_key from="categoryid" to="categories"/><![CDATA[
SELECT DISTINCT X1."customerid",X5."categoryid"
 FROM "customers" AS X1, "orders" AS X2, "orderdetails" AS X3, "products" AS X4, "categories" AS X5
 WHERE
 X1."customerid"=X2."customerid"
 AND X2."orderid"=X3."orderid"
 AND X3."productid"=X4."productid"
 AND X4."categoryid"=X5."categoryid"]]>
    </view>
</config>