<?xml version="1.0" encoding="UTF-8"?>
<!--
CAUTION: Do not modify this file unless you know what you are doing.
 Unexpected results may occur if the code is changed deliberately.
-->
<dbmodel pgmodeler-ver="1.1.0" use-changelog="false" author="Raphael Araújo e Silva" max-obj-count="6"
	 last-position="0,0" last-zoom="1.05" scene-rect="0,0,1570.8,1076.8"
	 layers="Default layer"
	 active-layers="0"
	 layer-name-colors="#000000"
	 layer-rect-colors="#1b81b4"
	 show-layer-names="false" show-layer-rects="false">
<role name="roletest"
 inherit="true">
</role>

<database name="exampledb" encoding="UTF8" is-template="false" allow-conns="true">
	<comment> <![CDATA[Example Database Model]]> </comment>
</database>

<schema name="public" layers="0" protected="true" fill-color="#000000" name-color="#000000" sql-disabled="true">
</schema>

<tag name="sample tag">
	<style id="table-body" colors="#ffffff,#ffffff,#000000"/>
	<style id="table-ext-body" colors="#ffffff,#ffffff,#000000"/>
	<style id="table-name" colors="#ffffff"/>
	<style id="table-schema-name" colors="#ffffff"/>
	<style id="table-title" colors="#ff0000,#800000,#000000"/>
	<style id="table-toggler-body" colors="#ffffff,#ffffff,#000000"/>
	<style id="table-toggler-btns" colors="#fcfcfc,#fcfcfc,#808080"/>
	<comment> <![CDATA[this tag is a test]]> </comment>
</tag>
	<language name="testlang"/>
<function name="trigger_func"
		window-func="false"
		returns-setof="false"
		behavior-type="CALLED ON NULL INPUT"
		function-type="IMMUTABLE"
		security-type="SECURITY DEFINER"
		parallel-type="PARALLEL UNSAFE"
		execution-cost="20"
		row-amount="2500">
	<schema name="public"/>
	<language name="testlang"/>
	<return-type>
	<type name="trigger" length="0"/>
	</return-type>
	<definition> <![CDATA[SELECT 1+1;]]> </definition>
</function>

<table name="table" layers="0" collapse-mode="2" max-obj-count="4" z-value="0">
	<schema name="public"/>
	<tag name="sample tag"/>
	<position x="40" y="40"/>
	<column name="column" not-null="true">
		<type name="serial" length="1"/>
	</column>
	<column name="column1">
		<type name="text" length="1"/>
	</column>
	<constraint name="table_pk" type="pk-constr" factor="10" table="public.&quot;table&quot;">
		<columns names="column" ref-type="src-columns"/>
	</constraint>
	<constraint name="table_uq" type="uq-constr" factor="10" table="public.&quot;table&quot;">
		<columns names="column1" ref-type="src-columns"/>
	</constraint>
	<constraint name="table_ck" type="ck-constr" table="public.&quot;table&quot;">
			<expression> <![CDATA[ column1 > 0 ]]> </expression>
	</constraint>
</table>

<index name="index" table="public.&quot;table&quot;"
	 concurrent="true" unique="true" fast-update="false" buffering="false" nulls-not-distinct="false"
	 index-type="hash" factor="0">
		<idxelement use-sorting="false">
			<column name="column1"/>
		</idxelement>
</index>

<table name="table1" layers="0" protected="true" collapse-mode="2" max-obj-count="4" z-value="0">
	<schema name="public"/>
	<position x="680" y="560"/>
	<column name="column" not-null="true" protected="true">
		<type name="serial" length="1"/>
	</column>
	<column name="column1" protected="true">
		<type name="text" length="1"/>
	</column>
	<column name="column2" not-null="true" protected="true">
		<type name="integer" length="1"/>
	</column>
	<column name="column3" protected="true">
		<type name="text" length="1"/>
	</column>
	<constraint name="table_pk" type="pk-constr" factor="10" protected="true" table="public.table1">
		<columns names="column" ref-type="src-columns"/>
	</constraint>
	<constraint name="table_uq" type="uq-constr" factor="10" protected="true" table="public.table1">
		<columns names="column1" ref-type="src-columns"/>
	</constraint>
	<constraint name="table_ck" type="ck-constr" protected="true" table="public.table1">
			<expression> <![CDATA[ column1 > 0 ]]> </expression>
	</constraint>
</table>

<rule name="rule1" event-type="ON INSERT" exec-type="ALSO"
 protected="true" table="public.table1">
		<condition> <![CDATA[column1 = 0]]> </condition>
		<commands> <![CDATA[UPDATE public.table1 SET column1 = 1]]> </commands>
</rule>

<trigger name="trigger1" firing-type="BEFORE" per-line="false" constraint="false"
	 ins-event="true" del-event="true" upd-event="true" trunc-event="false" protected="true"
	 table="public.table1">
		<function signature="public.trigger_func()"/>
</trigger>

<relationship name="table1_has_many_table" type="rel1n" layers="0"
	 src-col-pattern="{sc}_{st}"
	 pk-pattern="{dt}_pk" uq-pattern="{dt}_uq"
	 src-fk-pattern="{st}_fk"
	 src-table="public.table1"
	 dst-table="public.&quot;table&quot;"
	 src-required="false" dst-required="false">
	<label ref-type="name-label">
		<position x="164.369" y="161.148"/>
	</label>
	<column name="attribute">
		<type name="integer" length="1"/>
	</column>
</relationship>

<view name="view" layers="0" collapse-mode="2" max-obj-count="3" z-value="0">
	<schema name="public"/>
	<position x="40" y="600"/>
	<reference object="public.&quot;table&quot;.column1" type="column" ref-name="c1" ref-alias="col1" use-columns="true"/>
	<reference object="public.table1.column2" type="column" ref-name="c2" ref-alias="col2" use-columns="true"/>
	<reference object="public.table1" type="table" ref-name="t3" use-columns="true"/>
	<definition> <![CDATA[ select 1+1 ]]> </definition>
</view>

<relationship name="rel_view_table" type="reltv" layers="0"
	 src-table="public.view"
	 dst-table="public.&quot;table&quot;"
	 src-required="false" dst-required="false"/>

<relationship name="rel_view_table1" type="reltv" layers="0"
	 src-table="public.view"
	 dst-table="public.table1"
	 src-required="false" dst-required="false">
	<label ref-type="name-label">
		<position x="9.79871" y="6.45926"/>
	</label>
</relationship>

<textbox name="textbox1" layers="0" protected="true" z-value="0" width="102.406" font-size="9">
	<position x="260" y="420"/>
	<comment> <![CDATA[Protected Textbox]]> </comment>
</textbox>

<table name="table2" layers="0" oids="true" collapse-mode="2" max-obj-count="4" z-value="0">
	<schema name="public"/>
	<position x="680" y="40"/>
	<column name="column" not-null="true">
		<type name="serial" length="1"/>
	</column>
	<column name="column1">
		<type name="text" length="1"/>
	</column>
	<column name="column2" not-null="true">
		<type name="integer" length="1"/>
	</column>
	<column name="column3">
		<type name="text" length="1"/>
	</column>
	<constraint name="table_pk" type="pk-constr" factor="10" table="public.table2">
		<columns names="column" ref-type="src-columns"/>
	</constraint>
	<constraint name="table_uq" type="uq-constr" factor="10" table="public.table2">
		<columns names="column1" ref-type="src-columns"/>
	</constraint>
	<constraint name="table_ck" type="ck-constr" table="public.table2">
			<expression> <![CDATA[ column1 > 0 ]]> </expression>
	</constraint>
</table>

<index name="index" table="public.table2"
	 concurrent="true" unique="true" fast-update="false" buffering="false" nulls-not-distinct="false"
	 index-type="hash" factor="0">
		<idxelement use-sorting="false">
			<column name="column1"/>
		</idxelement>
</index>

<foreigndatawrapper name="fdw_test">
	<role name="roletest"/>
</foreigndatawrapper>

<foreignserver name="server_test">
	<role name="roletest"/>
	<foreigndatawrapper name="fdw_test"/>
</foreignserver>

<foreigntable name="foreign_table" layers="0" gen-alter-cmds="true" collapse-mode="2" max-obj-count="1" z-value="0">
	<schema name="public"/>
	<role name="roletest"/>
	<foreignserver name="server_test"/>
	<position x="680" y="400"/>
	<column name="id" not-null="true">
		<type name="smallint" length="0"/>
	</column>
</foreigntable>

<constraint name="table2_fk" type="fk-constr" comparison-type="MATCH FULL"
	 upd-action="NO ACTION" del-action="NO ACTION" ref-table="public.&quot;table&quot;" table="public.table2">
	<columns names="column2" ref-type="src-columns"/>
	<columns names="column" ref-type="dst-columns"/>
</constraint>

<relationship name="rel_table2_table" type="relfk" layers="0"
	 src-table="public.table2"
	 dst-table="public.&quot;table&quot;" reference-fk="table2_fk"
	 src-required="false" dst-required="false">
	<label ref-type="name-label">
		<position x="30.9966" y="-84.4807"/>
	</label>
</relationship>

</dbmodel>
