English 中文(简体)
如何执行带有阶级表继承权的身份地图?
原标题:How to implement Identity Map with Class Table Inheritance?

我在PHP中写一个数据映射器, 并试图研究如何执行身份地图, 当我的域目标跟随分类表继承时, 如何执行身份地图 。

我认为,问题在于,身份地图不能保证数据在模拟模型中只显示一次,因为等级物体依赖于等级数据。

例如,在我的数据库中,我有一个家长表和一个孩子表。在我的域名模型中,我有一个家长类,从中延伸了一个孩子类。我可以即时地将一个父母对象和一个孩子对象记录在身份地图上,没有问题。如果客户代码要求同一位父母或孩子,我可以从我的缓存中归还它,而不是数据库,没有问题。

但是,如果父母和子女都与同一父母记录有关呢?即父母表中的数据相同呢?我现在有该数据在模拟中两次表示,如果在一次(或两次)中修改过,我冒着承担这些修改的风险。

在我看来,身份地图似乎需要遵循类似于“域目标”和“映像师”本身的等级体系,然而在这一点上却变得有点复杂。 另外,我还有很多附属地图需要考虑。

任何想法/建议都非常感激!

最佳回答

我定义了一个界面, iQueable, 只有执行此界面的对象才能被排队, 以便将其更改写入数据库 。

子对象具有全部对象属性的全称,因此它们会执行iQueable。父对象不能排队。

这仍然允许父母和儿童对象脱离同步,但现在只有一个数据库变更来源。

问题回答

如果您发现您有许多重复/重复的数据, 设计是错误的...

I. e. 如果父母一方有孩子共同的地址,您应该有一个地址表,这些记录中的每一记录都将指向地址表中的单项等。

然后它会重新应用相关规则, 即如果儿童账户中的地址被更改... 您会怎么做? 更新( 这意味着父母也会有新的地址) 或插入新的地址 。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签