Questions tagged [polymorphic-associations]
The polymorphic-associations tag has no usage guidance.
Model types of an entity [duplicate]
Let's take a simple users table. I have a few different type of users. Let's simplify it into two, employees and customers, for the sake of the example, but keep in mind I do have much more. So I have ...
Insert into table with polymorphic association in database
I want to design a database where some tables have multiple foreign keys. I am looking for the best design approach. I found out that this kind of problem is called "polymorphic association" ...
DB design - logging transactions
I am trying to implement a booking system for charging stations that can either extend or refund a booking. I basically have the following tables: booking booking_logs payment refunds With how the ...
What is the best DB schema to handle exceptions and prevent redundancy?
There are some products that can be sold in multiple units and the base unit is kilogram. The unit of each product has different weight, for example a Bundle of product A is 20kg but a Bundle of ...
A question about foreign keys and many to many relationships
My question is mostly conceptual in nature. I have a database schema that involves a many-to-many relationship between a School table and Student table. This seems sensible to me, given that a school ...
payment table in relational datase
I have to model a database table for payments. These need to have two fields payment from and payment to and this needs to link to two tables one is clientA and clientB as in the representation below. ...
How to model a relationship with variable tables (polymorphism)?
What is the best way to model the following kind relationship? Let's say I have tables representing two types of entities: company and person. I have a customer table with an entity_id field, which ...
Database Designs Alternative to Polymorphism in Establishing Relationships
I'm working on a database which handles replacement of parts in a machine. Rules A machine has many components A machine has a set of assembly instructions Many components have many part (screws, ...
Best practise for polymorphic associations in MySQL
I have a MySQL database with 3 tables holding the main classes of data: companies (company_id) persons (person_id, company_id) loans (loan_id, company_id) Both a 'loan' and a 'person' belong ...
Performance impact of NOT using a foreign key (many dedicated 1:many key-key tables vs non-fk generic key-key table)
We're using a lot of association tables to manage 1:many relationships among a variety of different objects in our system. To illustrate the question, two examples would be: users, events, ...
MySQL - Creating an associative table
I have the following table structures: Cases: (PK) case_id | case_notes | time 1 | blah | timestamp 2 | blah | timestamp 3 | blah | timestamp . | . ...
Can triggers be used to implement automated polymorphic association?
(Apologies for any bad formatting or ignorance of common practices within this community; this is my first question here.) I'm attempting to (re)design a MySQL database for a personal social ...
Do supertables produce bottlenecks?
There are several alternatives to using polymorphic associations and one of them is to use the so-called "concrete supertable". From my point of view, this is the neatest solution and is pretty easy ...
Enforcing constraints "two tables away"
I ran into some trouble modeling an electrical schematic in SQL. The structure I'd like to capture is part ←────────── pin ↑ ↑ part_inst ←───── pin_inst where "inst" is short for ...
Is there a well-known name for this "poor man's ref. integrity" schema design pattern?
Is there a name for the following database schema design/pattern? My eventual goal is to find more literature about the subject. Today's cursory net search was too full of generic words to be able pin ...
Polymorphic Association - is it bad? [duplicate]
In the following schema: Collections Upvotes Reports Upvotes Reviews Upvotes I'm tempted to have a single Upvotes table with a single "entityId" column that stores either the CollectionId, ...
How to design database for polymorphic relationships
I have the following scenerio: There are some categories Each category has attributes An attribute could be of free text or collection of options There is a product which is assigned to category ...
Foreign key with multiple references
I have the following three tables in mysql database named "THE_COLLEGE" mysql> desc students; +----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | ...