<div>Hello,<br></div><div><div class="gmail_quote"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><br></div><div>I ran into some problem when building the entity relationship with Pony ORM. Following are two tables in the database.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font size="1">TABLE `branches` (<br> `id` int(11) NOT NULL,<br> `client` varchar(64) NOT NULL,<br> `pid` int(11) DEFAULT NULL,<br> PRIMARY KEY (`id`,`client`),<br> KEY `branches_ibfk_1` (`pid`),<br> CONSTRAINT `branches_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `branches` (`id`)<br>)<br>TABLE `branches_config` (<br> `id` int(11) NOT NULL AUTO_INCREMENT,<br> `bid` int(11) NOT NULL,<br> `client` varchar(64) NOT NULL,<br> PRIMARY KEY (`id`),<br> KEY `branches_config_ibfk_1` (`bid`,`client`),<br> CONSTRAINT `branches_config_ibfk_1` FOREIGN KEY (`bid`, `client`) REFERENCES `branches` (`id`, `client`)<br>)</font></blockquote><div> </div><div>For the 'branches' table, 'id' is a part of the primary key and also referred by 'pid'. I tried to define 'id' as a Set attribute to satisfy the one-to-many self-reference. But Set attribute cannot be a part of primary key. Could you tell me how to define such a relationship?<br></div><div><br></div><div>For the 'branches_config' table, (bid, client) refers 'branches' (id, client). How to define the reference between two composite key?</div><div><br></div><div>Thank you and I look forward to hearing from you.</div><div><br></div><div>Best wishes,</div><div>Agatha</div></div></div></div></div>
</div></div>