class-table-inheritance

How do we implement an IS-A Relationship?

断了今生、忘了曾经 提交于 2020-01-09 12:18:06
问题 We implement an One-to-Many relationship by adding one Table's PK, as FK to the other Table. We implement a Many-to-Many relationship by adding 2 Table's PKs to a third Table. How do we implement an IS-A Relationship ? The Entities are TECHNICIAN and ADMINISTRATIVE which both are EMPLOYEE. I could just use an extra field in the Table EMPLOYEE(id, name, surname, role , ...AdminFields..., ...TechFields...) but i would like to explore the IS-A option. EDIT: I did as Donnie suggested, but without

Inheritance & Database Design

痞子三分冷 提交于 2019-12-25 01:53:21
问题 When you model inheritance through class table inheritance relationships in a database model, do you... 1) Include an attribute (boolean for two subtipes, string for more subtipes) which identifies the particular subtipe of each record? 2) Include this identification as a foreign key to a table containing a description of all the possible subtypes? 3) None of the above and rely on "trial and error" lookup in subtables on the few times it is needed? 回答1: I would prefer in most cases the table

What are the possible solutions to OO/Table inheritance (ie. STI,MTI,CLI) in Rails 5+?

放肆的年华 提交于 2019-12-24 02:44:12
问题 These are the options I see that can help solve "Rails 5 - Object Relation Impedence and how to structure multiple inherited classes/tables" TL;DR - the Object Table Impedance ORM problem. Abstract base class, with each child class having its own table (ie storing the common attributes for each type in its own table) STI, just put everything in one Base class and Table, and create all child attributes in that table, but have the sub-classes (ie your other Rails models) inherit from that Base

Avoid Circular Dependency

て烟熏妆下的殇ゞ 提交于 2019-12-21 02:28:17
问题 I am developing a travel management application. The design in question is something like following : Each person in a tour is designated as a Traveler. Each Traveler has a Passport. Now, a Traveler can be a MainMember or a SubMember, depending on whether or not he is the head of the family. A MainMember decides stuff like TourPackage, total amount for his travelling family, etc. A SubMember is dependent on the MainMember while travelling. So, if a MainMember is deleted, all its SubMembers

Hierarchical database model

无人久伴 提交于 2019-12-20 06:49:08
问题 I'm designing a classifieds website about pets that will have 3 (main) categories of ads: A- Sale B- Breeding C- Jobs The problem I'm facing is that all 3 ad categories have some things in common, but they also have some differences. For example, categories A, B and C all have the following in common: category_id ad_id user_id location However, category B ads cannot be classified as "Looking For/For Sale", whereas B & C can. Furthermore, each category will have its own subcategories. For

How to change and entity type in Doctrine2 CTI Inheritance

时间秒杀一切 提交于 2019-12-18 04:42:21
问题 How (if possible at all) do you change the entity type with Doctrine2, using it's Class Table Inheritance? Let's say I have a Person parent class type and two inherited types Employe and Client . My system allows to create a Person and specify it's type - that's fairly easy to implement - but I'd also like to be able to change the person from an Employe to a Client, while maintaining the Person -level information (it's id and other associated records). Is there a simple way to do this with

Doctrine 2.1 - Map entity to multiple tables

无人久伴 提交于 2019-12-17 16:58:19
问题 I have the following database situation: wp_users (user table generated by wordpress) ID | user_login | ... wp_sp_user (extension to the wp_users table) ID (FK) | surname | address | ... Now I've already been trying for hours to "fuse" those two tables into one single User entity, e.g: class User { var ID; var user_login; var surname; var address; ... } Is there any way to accomplish such a mapping without modifying the wp_user table (which I don't want to do for updating reasons)? 回答1: Some

Techniques for database inheritance?

淺唱寂寞╮ 提交于 2019-12-17 03:36:11
问题 What are the tips/techniques when you need to persist classes with inheritance to relational database that doesn't support inheritance? Say I have this classic example: Person -> Employee -> Manager -> Team lead -> Developer -> Customer -> PrivilegedCustomer -> EnterpriseCustomer What are the available techniques to design the database? Pros and cons of each? p.s. I have searched and found several question regarding database inheritance but most were about changing to a database engine that

How to convert entity leaving it id

眉间皱痕 提交于 2019-12-10 20:44:33
问题 There are some entities (Region, Country, City) wich used STI (or even CTI). How it possible convert Country to City leaving old id? 回答1: This is not supported in Doctrine 2 because type casting user objects is not supported by PHP. With that said, Doctrine uses the discriminator column to determine what type of object to hydrate. If you change the value of the discriminator column in the database with a SQL UPDATE, the object type will be changed the next time the object is loaded. This

How to map collection of each subclass from same hierarchy onto one owning class?

天涯浪子 提交于 2019-12-06 12:07:20
问题 Does anyone know how to map a collection of each subclass from the same hierarchy onto one owning class, using JPA 2.0 annotations, backed by Hibernate 4.0.0.Final? Bit convoluted, so here's an example. Hierarchy classes look like this: @Entity @Cacheable(true) @Table(name = "hierarcicals") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "class", discriminatorType = DiscriminatorType.STRING) public abstract class MySuperClass { ... @Entity @DiscriminatorValue(