Refers to database tables with a column that is a foreign key to another column within the same table.
Questions tagged [self-referencing-table]
131 questions
0
votes
1 answer
Doctrine 2 ZF3 self referencing entity is not updating all fields of parent
I have a self referencing entity with parent and children. The strange thing is, when I add the form elements (DoctrineModule ObjectSelect) for parent and children to the form, some other fields of the parent entity doesn't update, when I persist…

Oskar
- 105
- 1
- 6
0
votes
1 answer
PHP Zend framework - Many layer menu
In my application, i want to make a dynamic multi layer menu like this
Toy1
==>Sub toy1-a
==>Sub toy1-b
Toy2
==>Sub toy2-a
==>Sub toy2-b
Toy3
==Sub toy3-a
I have created 2 table in database called parent-Menu contain Toy1,Toy2,Toy3 and sub-Menu…

agmadon
- 29
- 2
0
votes
0 answers
How to flat data graph using Entity Framework?
I have this query :
dbContext.OrganizationHierarchyItems
.Include(x => x.Parent)
.Include(x => x.SubOrganizationHierarchyItems)
.Where(x => x.Parent==null)
.ToList();
And I need to flat all…

Simple Code
- 2,354
- 2
- 27
- 56
0
votes
1 answer
Product and Category relationship
Trying to have following relationship in my application.
Product can belong to many categories, sub categories and sub sub categories.
Current design:
Product:
has_many :categorizations, dependent: :destroy
has_many :categories, through:…

rAzOr
- 300
- 6
- 19
0
votes
2 answers
Friendship self referential association
I've been trying to implement a Facebook style friend system. I've read several tutorials and can't understand what I'm doing wrong. The friendship controller and the links in the views for adding friends work, but on the database level it throws an…

mef27
- 379
- 4
- 15
0
votes
2 answers
How to create a self referencing table using code first?
I have an entity that has a reference to itself in a parent - child relationship. I need to find out how to implement this using code first and fluent API. Below is my entity class.
public class MenuItem
{
public int Id { get; set; }
public…

Dinusha
- 11
- 1
- 4
0
votes
2 answers
Creating Concatinated parent column with MySQL on self referencing query
I am trying to populate ElasticSearch with a collection of documents along with a field representing the path to the document based on its parents.
Here is my table layout:
+----+--------+-------+----------+
| Id | Parent | Alias | Contents…

Cardboard
- 25
- 4
0
votes
0 answers
Which MySQL concept do I need to read about to query a "Collection" entity inside itself and get a Tree like result as a table?
So, I have modeled these entities:
Feed
Collection
Where I have these relationships:
A Feed has a Collection, and a collection alone (1 to 1)
A Collection may have any number of Feeds (1 to N)
A Collection may have any number of Collections (1…

nmdias
- 3,888
- 5
- 36
- 59
0
votes
0 answers
Ruby/Rails: Efficient way to build a nested array of object
I'm developing an API that deals with localities. I have a table that has been build as a self-referential and contains a parent_id column. I have so far 144 records in that table.
Our client app needs to receive nested localities. Since I'm using…

lkartono
- 2,323
- 4
- 29
- 47
0
votes
1 answer
create breadcrumbs by self-referencing table
Is it possible to create breadcrumbs list on my website product page using PHP from table self-referencing structure.
I try to loop from product to get the root category but the result is backward.
or I try to get root category first and loop it but…

Wilson
- 45
- 9
0
votes
2 answers
Self References
For an assessment task I'm doing, an entity album has the attribute also_bought, which is a self-referential attribute. However, this one attribute has multiple entries for any one album - as the also_bought recommendations are rarely only one…

Leafsw0rd
- 157
- 8
0
votes
2 answers
How to create a self-referencing one-to-many relationship in Flask-SQLAlchemy?
I have a model named Post, which has a boolean field called is_answer. If the is_answer field of a Post is True, it's a "question"; otherwise, it's an "answer". I want to create the following question-answer relationship:
One "question" may have…

nalzok
- 14,965
- 21
- 72
- 139
0
votes
1 answer
RejectChanges Self-relation in DataSet
I have a problem rejecting a DataSet with self-related tables.
First I insert a parent row and a child row in a table. Then I call RejectChanges method from the table object or the same method from the DataSet. The RejectChagnes method throws…

Asier Cayón Francisco
- 137
- 9
0
votes
0 answers
Symfony 2.8 Entity Self-relation running out of memory with many records
On my sf 2.8 project got the following entity with self relation, used to store tourist destinations, for example a parent could be Caribe, children Jamaica, and children Kingston
class Destination
{
/**
* @var integer
*
* @ORM\Column(name="id",…

Randy
- 33
- 7
0
votes
1 answer
Optimize table design for "SQL Where Clause"
I am working on a database design for Where clauses of SQL. My application is a workflow engine that allows the end-user to specify the where clause of an SQL. Currently my application supports creation of where clause as follows:

Jo Kachikaran
- 562
- 1
- 6
- 12