PIM.cphrase

Here you can browse the full pim.phrase. Note the use of views and reports.

<?xml version="1.0" encoding="UTF-8"?>
<config id="PIM" db="sqlite:PIM.db" language="english">

    <table id="Note" writes="full">
        <column id="id" type="int"/>
        <column id="title" type="text"/>
        <column id="type" type="text"/>
        <primary_key key="id"/>
        <primary_value key="title"/>
    </table>

    <table id="Note_Attachment" writes="full" lex="attachment">
        <column id="note" type="int" select="false"/>
        <column id="file" type="file"/>
        <foreign_key from="note" to="Note"/>
    </table>

    <table id="Exercise" writes="full">
        <column id="id" type="int"/>
        <column id="type" type="text">
            <value val="kettlebell"/>
            <value val="skiing"/>
            <value val="bicycle"/>
            <value val="run/walk"/>
            <value val="run"/>
            <value val="desk work"/>
            <value val="hard labor"/>
            <value val="outside time"/>
        </column>
        <column id="date" type="date" default="(date('now'))"/>
        <column id="description" type="memo"/>
        <column id="measure_title" type="text"/>
        <column id="measure" type="real"/>
        <primary_key key="id"/>
    </table>

    <table id="Task" writes="full" lex="task,tasks">
        <column id="id" type="int"/>
        <column id="name" type="text" notnull="true" properties="+quotes"/>
        <column id="priority" type="text" notnull="true">
            <value val="high"/>
            <value val="low"/>
            <value val="medium"/>
        </column>
        <column id="severity" type="text" notnull="true">
            <value val="high"/>
            <value val="low"/>
            <value val="medium"/>
        </column>
        <column id="posted" type="date" default="(date('now'))"/>
        <column id="starred" type="boolean" default="0"/>
        <column id="notes" type="memo"/>
        <column id="task_type" type="int" default="1" select="false"/>
        <primary_key key="id"/>
        <foreign_key from="task_type" to="Task_Type"/>
        <primary_value key="name"/>
    </table>

    <table id="Task_Type" writes="full" lex="project,projects,task category,task categories,task type,task types">
        <column id="id" type="int"/>
        <column id="name" type="text"/>
        <column id="area" type="text" properties="+value-stands-for-table"/>
        <column id="description" type="memo"/>
        <primary_key key="id"/>
        <primary_value key="name"/>
    </table>

    <table id="Eating" writes="full" lex="eating,eatings,ate,eaten">
        <column id="food" type="text" lex="food" select="false"/>
        <column id="date" type="date" default="(date('now'))" lex="when" properties="+value-stands-for-column"/>
        <column id="helping" type="real" default="(1.0)" units="portions" lex="helping,helpings,quantity"/>
        <virtual_column id="id" type="text" properties="-project"><![CDATA[
replace(replace($VAR.food,',',''),'''','') || $VAR.date
]]></virtual_column>
        <primary_key key="id"/>
        <foreign_key from="food" to="Food"/>
    </table>

    <table id="Food" writes="full" lex="food,foods">
        <column id="name" type="text" notnull="true" properties="+like"/>
        <column id="calories" type="real"/>
        <column id="notes" type="memo"/>
        <primary_key key="name"/>
    </table>

    <table id="Journal" writes="full" lex="journal,journals">
        <column id="id" type="int"/>
        <column id="posted" type="date" default="(date('now'))"/>
        <column id="notes" type="memo"/>
        <primary_key key="id"/>
    </table>

    <view id="Daily" lex="calorie report,calorie reports">
        <column id="date" type="date"/>
        <column id="calories" type="real"/>
        <primary_key key="date"/><![CDATA[
select sum(helping * calories) as calories, date
from Eating, Food
where eating.food = Food.name
group by date
]]>
    </view>

    <report purview="SELECT X1.* FROM Daily AS X1" handler="bar"><![CDATA[
SELECT date, calories FROM ($SUB)
]]></report>

    <report purview="SELECT X1.* FROM Task AS X1" handler="table"><![CDATA[
SELECT edit,id,name,posted,LENGTH(notes) as note_length FROM ($SUB) ORDER BY name ASC
]]></report>

    <report purview="SELECT X1.* FROM Food AS X1" order="ORDER BY upper(name)" handler="table"><![CDATA[
$SUB $ORDER
]]></report>

    <report purview="SELECT X1.* FROM Note_Attachment AS X1" handler="table"><![CDATA[SELECT DISTINCT (SELECT Y1.title FROM Note as Y1 WHERE Y1.id = X1.note) as note_title, '<img src="static/files/' || X1.file || '"/>' as image
 FROM ($SUB) AS X1]]></report>

    <cascade>
        <pre from="order by" to="order by increasing"/>
    </cascade>

</config>