A technique that maps an inheritance hierarchy of objects to a single table in relational database.
Questions tagged [table-per-hierarchy]
133 questions
1
vote
1 answer
Entity Framework TPH with multiple abstract inheritance
I'm trying to do a Table Per Hierarchy model in Entity Framework(VS 2008 sp1, 3.5).
Most of my models have been very simple, an abstract type with multiple sub-types that inherit from it.
However, I've been struggling with this latest challenge. I…

itchi
- 1,683
- 14
- 30
1
vote
0 answers
C# Table Per Hierarchy Projection Union
I'm using table per hierarchy to project to model classes. When I use of type in Linq to Entities, all of my results are always the last type which was projected. What I mean is if I have these for domain models:
public interface IPerson { string…

Furynation
- 537
- 1
- 5
- 14
1
vote
1 answer
Does Breeze work with Table Per Hierarchy (TPH)
I'm trying to plug BreezeJs into an existing datastructure and getting an error in the meta data fetch. I can replicate this by adding the following to the CarBones sample
namespace CarBones.Models
{
public abstract class VanBase
{
public…

Andiih
- 12,285
- 10
- 57
- 88
1
vote
1 answer
Improving my database design using TPH Inheritance
This is my current database design, for the moment just look the student, teacher and classes tables.
I'm trying to convert some tables into news using TPH Inheritance. For example.
Create a new table called Person where…

Darf Zon
- 6,268
- 20
- 90
- 149
1
vote
0 answers
Detect loops in hierarchy using SQL Server query
Possible Duplicate:
SQL - detecting loops in parent child relations
I have a simple table with 2 columns id and parentid:
id | parentid
------------------
2 1
3 2
4 3
1 4
For example, in the above table, 1 is…

mhn
- 2,660
- 5
- 31
- 51
0
votes
1 answer
Entity Framework Table Per Hierarchy restrictions
I have very big table in my Database and a can't modify it.
So i have BaseEntity type for table.
I have several children (entity1, entity2) and i'd like to map each type to same column ("Date") and name properties differently.
Surely i can't move…

Denis Agarev
- 1,531
- 4
- 17
- 34
0
votes
1 answer
How can I update the concrete class within hibernate's table-per-class-hierarchy strategy?
I've employed hibernate's table-per-class-hierarchy as outlined here.
I've got a simple 1-tier hierarchy where the parent includes a number of attributes and the child(ren) include more of the same. There are also relationships to the the object. …

Raymond Kroeker
- 525
- 1
- 5
- 13
0
votes
0 answers
Multiple child compositions to the same type w/ Entity Framework & Table Per Hierarchy (TPH) Inheritance
I am modeling an inheritance hierarchy as shown below:
I want to model the BaseClass hierarchy as "Table Per Hierarchy" (TPH). Any of the derived types of BaseClass can have children in the ChildClass table. To be clear, this is a true Parent /…

Wade Baird
- 194
- 1
- 16
0
votes
2 answers
EF Table per Hierarchy (TPH) not saving because can't insert value null in Discriminator column
I have a table used for multiply type of category and it contains a Discriminator column named 'ClassName' to specify the type of object to load. The ClassName column is non nullable with a default value of 'Category'
My problem is when saving a new…

freddoo
- 6,770
- 2
- 29
- 39
0
votes
0 answers
From several lines a hierarchy into one line
I have a table with data hierarchy
CREATE TABLE my_table(
object_id varchar,
parent_id varchar
);
INSERT INTO my_table(object_id , parent_id)
VALUES
('1', '0'),
('2', '0'),
('3', '1'),
('4', '1'),
('5', '1'),
('6', '3'),
('7', '2'),
('8',…

Maxim
- 25
- 4
0
votes
1 answer
How to access a TPH type's property in a LINQ expression tree?
I have 2 SQL Server tables, Order and OrderDetail. I have 3 C# classes based on those tables: Order maps to table Order, while OrderDetail and SpecialOrderDetail map to table OrderDetail using TPH with OrderDetail being an abstract base class and…

formicini
- 298
- 4
- 16
0
votes
0 answers
Table per Hierarchy without discriminator in EF core
There is a existing database and we have multiple columns to decide Table Per Hierarchy.It is not convenient to add any new column as discriminator. We have Table Per Hierarchy database structure as below.
Product - Base Entity (Database…

Jatin Dave
- 734
- 1
- 7
- 14
0
votes
1 answer
Getting DAOs for Table-per-Hierarchy structure
Let's assume I have a User class and two subclasses Employee and Customer. I implemented this hierarchy as a table-per-hierarchy in DB with a column for specifying the type of user. I need to return the right type of object when querying this table.…

doctrey
- 1,227
- 1
- 12
- 25
0
votes
1 answer
EF Core Table Per Hierarchy - Is it possible to keep track of collections for specific Entity?
Lets say I would implement a Table Per Hierarchy for a class where I would store subclasses of this type distinguished by a discriminator (~ 5 types).
Some subclasses will have their own ICollections and some wont, so this will not be specified in…

Glanie
- 17
- 4
0
votes
1 answer
Table per hierarchy layout problems in EF 4.1 with multiple nullable discriminators
I have a table with an int PK, one NOT NULL field, and two NULL string fields.
When I go and set up a TPH-style design in EF, I set it up this way:
The top level type only has the PK and the NOT NULL field.
The first level checks the first nullable…

kappasims
- 124
- 9