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
0 answers
RecursionError on SQLAlchemy when using Loader options to eager load self referencial relationship
I am working with the following project: A CRUD for a system with dynamic models. To utilize SQL Alchemy ORM features, I am using automap_base to load the table models and be able to traverse the relationships and such.
In one particular case, I…

Idel
- 1
- 1
- 1
0
votes
0 answers
How to perform updates on model's association (belongsToMany) in Sequelize?
I have a model in my database - User.
The User has a self references which is defined as User.belongsToMany(User, { through: "UserFriends", as: "friends" });.
I have looked through the documentation and was not able to find an example of how to…

Eddie Lam
- 579
- 1
- 5
- 22
0
votes
1 answer
Creating nested JSON array for self-referencing table
I have the following self-referencing table:
CREATE TABLE [dbo].[Assets](
[id] [int] IDENTITY(1,1) NOT NULL,
[Part] [nvarchar](500) NOT NULL,
[ParentId] [int] NULL,
CONSTRAINT [PK_Assets] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH…

Alex Wright
- 421
- 1
- 11
0
votes
1 answer
Self referencing many-to-many relationship with extra column in association object
I am new in Sqlalchemy and trying to achieve the following goal with relationship():
There is an User table which stores user data.
Every user is able to invite other user with an invite_code.
Every user keeps a list of invitation, every invitation…

Kevin
- 21
- 6
0
votes
1 answer
Do self referencing entities need @OneToOne JPA annotations or not?
Imagine an Entity A has a non-mandatory one-to-one relationship with itself, say something like the diagram below.
Do I write sourceTransaction and destinationTransaction as: public DepositAccountTransaction sourceTransaction; public…

FlyingSquid
- 57
- 6
0
votes
1 answer
How do I set up a has_many, polymorphic, self-referential relationship
I'm trying to set up a relationship like this:
I am making a list of all recipes across multiple recipe books. A recipe can only belong to one recipe book. A recipe has a list of components, which can either be an individual ingredient or another…

AELSchauer
- 33
- 4
0
votes
1 answer
getting data in self-referencing relation with TypeORM
This is my entity :
@Entity()
export class Comment extends BaseEntity {
@PrimaryGeneratedColumn()
id: number
@Column({ type: "text" })
body: string
@Column()
displayName: string
@OneToMany(() => Comment, comment =>…

AR Second
- 582
- 1
- 6
- 25
0
votes
0 answers
How to implement a dynamically nested sidebar menu in WPF?
I want to implement a sidebar as a UserControl in WPF.I want to load the content of the sidebar dynamically from the database. I can add any menu i can remove any, i can change the level of nesting from database. is there a way to do that with XAML…

rcode
- 23
- 5
0
votes
1 answer
Self-referencing many-to-many relationship with an association object in SQLAlchemy
I've found examples for a self-referencing many-to-many relationship with an association table. How can I achieve the same using an association object?
The code below is based on: How can I achieve a self-referencing many-to-many relationship on the…

testo
- 1,052
- 2
- 8
- 24
0
votes
1 answer
Self referencing JPA Entity to satisfy interface definition
I have a spring + Data JPA setup which contains several Entities that inherit from interface definitions like this (in “pseudo” Java):
@Entity
A implements WithSubProperty
@Id
Long Id
SubProperty subProperty
…
@Entity
B implements…

user462982
- 1,635
- 1
- 16
- 26
0
votes
2 answers
Integer to guid primary key database migration
I'm trying to migrate from int based primary keys to guid based system, and I'm having trouble with migrating self referenced table
Entity
---------
ID
ParentID
AnotherParentID
When querying the table I'm creating new guid ID for each row, but how…

zhuber
- 5,364
- 3
- 30
- 63
0
votes
2 answers
Recursive self referenced table to flat structure
Entity
---------
ID
TypeAID
TypeBID
TypeAID and TypeBID are nullable fields where row can have one, both or none values entered, and both IDs are pointing to same table Entity.ID (self reference).
Is there any way to go recursive through 3 level…

zhuber
- 5,364
- 3
- 30
- 63
0
votes
1 answer
Fetch parent child relation with level from the same table
Hi I'm new with django and python.
# function for fecthing the child
def get_childern(request, username):
Q = list(Profile.objects.filter(sponsor_id__exact=username))
populate(request, Q, username)
# Iterate the Queryset
def…

Umesh
- 7
- 2
- 5
0
votes
1 answer
How can I bind non-null self referencing entity?
I'm trying to bind a table looks like this
some_id BIGINT PK
parent_id BIGINT NN '0'
As you can see,
It looks like a self-referencing entity
No FK for parent_id
parent_id is not nullable and defaults to 0
How can I bind?
Does following…

Jin Kwon
- 20,295
- 14
- 115
- 184
0
votes
1 answer
sqlalchemy self-referencing many-to-many with "select" as association table
Problem description
I'm using sqlalchemy (v1.2) declarative, and I have a simple class Node with an id and a label. I would like to build a self-referencing many-to-many relationship where the association table is not a database table, but a dynamic…

PiQuer
- 2,383
- 25
- 29