circular-reference

Database design: circular references

半城伤御伤魂 提交于 2019-12-05 20:04:40
I have three database tables: users emails invitations Emails are linked to users by a user_id field. Invitations are also linked to users by a user_id field Emails can be created without an invitation, but every invitation must have an email. I would like to link the emails and invitations tables so it is possible to find the email for a particular invitation. However this creates a circular reference, both an invitation and an email record hold the id for the same user. Is this bad design and if so, how could I improve it? My feeling is that with use of foreign keys and good business logic,

How can I get all parents' parents as columns for child object in circularly referenced table?

家住魔仙堡 提交于 2019-12-05 19:56:10
I have a table with columns like entityID, entityName, parentID How can I write a query to return all the levels of parents for an entity as to return something like childentityname, parentlevel1name, parentlevel2name, parentLevel3name and so on I am not a SQL ninja by any means. Is this possible? If so, how? I'm using Microsoft SQL Server DB. A recursive CTE is what you need look here (EDIT: Only in SQL SERVER 2005+) Something along the lines of: WITH recurse_cte (entityID,entityName, parentID, Level) AS ( -- Anchor member definition SELECT e.entityID,e.entityName, e.parentID, 0 AS Level FROM

Learning Haskell: Seemingly Circular Program - Please help explain

为君一笑 提交于 2019-12-05 18:23:39
问题 I'm currently going through the book "The Haskell Road to Logic, Math, and Programming" by Doets and Van Eijck. I've never been exposed to any functional programming language until this book, so keep that in mind. Still early in the book, it gives the following code for a primality test: ldp :: Integer -> Integer ldp n = ldpf primes1 n ldpf :: [Integer] -> Integer -> Integer ldpf (p:ps) n | rem n p == 0 = p | p^2 > n = n | otherwise = ldpf ps n primes1 :: [Integer] primes1 = 2 : filter prime

Symfony serializer - set circular reference global

北城余情 提交于 2019-12-05 17:16:28
问题 Is there any way to set the circular reference limit in the serializer component of Symfony (not JMSSerializer) with any config or something like that? I have a REST Application with FOSRestBundle and some Entities that contain other entities which should be serialized too. But I'm running into circular reference errors. I know how to set it like this: $encoder = new JsonEncoder(); $normalizer = new ObjectNormalizer(); $normalizer->setCircularReferenceHandler(function ($object) { return

Symfony 3.0.4 Circular reference detected during serialization with FOSRestBundle

丶灬走出姿态 提交于 2019-12-05 16:46:56
I'm using FOSRestBundle in a Symfony project. When it I try to handle a view, it fails during the serialization of my data with the Symfony serializer as well as with the JMSSerializer. This is the method rendering the response: DefaultController.php $em = $this->getDoctrine()->getManager('magellan'); $qb = $em->createQueryBuilder(); $query = $qb->select('h') ->from('DataBundle:Holding', 'h') ->where($qb->expr()->eq('h.id', ':holding_id')) ->setParameter('holding_id', $holding_id) ->getQuery(); $results = $query->getResult(); $view = $this->view($results, 200); // Everything's ok up to this

Python Delegate Pattern - How to avoid circular reference?

情到浓时终转凉″ 提交于 2019-12-05 15:15:58
I would to ask if using the Delegate Pattern in Python would lead to circular references and if so, what would be the best way to implement it to ensure the object and its delegate will be garbage collected? In Objective C, the above problem is avoided by using a weak reference to the delegate. In C++, we don't call delete on the delegate. I've found a link to Python's weak reference module here: http://docs.python.org/library/weakref.html . It seems like a plausible approach might be to create a weak reference to refer to the instance variable using this module but I'm not sure. As I've

Reason for circular references with classes?

北慕城南 提交于 2019-12-05 10:17:39
I'm aware of circular references (class a holds class b and class b holds class a). But since I haven't programmed enough, it's hard for me to find reasons to use them. I was wondering if people could give me some nice examples and possibly explain good reasons for using them. For example, right now I'm looking at 2D source code tutorials and the user created a Creature and a CreatureAi class that reference each other. For what reason? I don't know yet, that's why I'm looking for examples and still reading around. The most obvious case of circular reference is self-reference: you need it for

Circular references between two classes

≯℡__Kan透↙ 提交于 2019-12-05 09:04:36
I know this must be a n00b question, but I have to implement a mockup client-server sequential interaction application, and because the number of client-server calls varies, I cannot just iterate the steps in an external function, always fetching data from the client and then forwarding it to the server and vice-versa, so I need to make my Server and Client classes be aware of each other so that they can call their public methods between themselves. One approach would be to design both as Singletons, but I was hoping to do it in a simpler way, more precisely using a circular reference: the

Test if variable contains circular references

假装没事ソ 提交于 2019-12-05 05:54:08
How do you test a variable for circular references? I am using PHP's var_export() function with the return string argument set to true . I found that Warning: var_export does not handle circular references and was wondering if anyone knew of a way to test if a variable contains a circular reference so that I may use it before trying to use var_export on it. I know that var_export outputs PHP eval-able text that can be used to recreate the array and even though I am not using it for that I still want to use this function when it is available because the output format meets my needs. var_dump is

How to properly design this part of a database (circular reference?)

元气小坏坏 提交于 2019-12-04 19:28:50
Situation: A company has many projects A project has many tags A project belongs to only 1 company A tag can belong to multiple projects A company must have access to its own tags Example 1: In the first image, all tags for the company are available through the projects/project_tag. But if all projects are removed, then the tags for the company will not be accessible anymore, because the link between project_tag and projects is gone. The tags should be somehow always be linked to the company, even if there are no projects. Example 2 (where tags are also linked to the company): In the second