2022 Developer Survey is open! Take survey.

Questions tagged [inheritance]

For questions about extending a base object's features into a derived object.

Filter by
Sorted by
Tagged with
0 votes
0 answers
68 views

How to implement concrete table inheritance pattern in MySQL?

I want to know how to implement classes in MySQL that represent a subset of another class type, with the purpose of having subclasses inherit fields from the parent class. Described by Martin Fowler ...
user avatar
  • 9
0 votes
1 answer
35 views

How can I query my "subtype" tables?

I am trying to model inheritance in my database. The purpose of the database is to use it to emulate a directory structure in a desktop GUI. The directory structure is made up of nodes, which can ...
user avatar
  • 103
1 vote
1 answer
94 views

Class Table Inheritance combined with running searches and paging

Assume we have tables similar to the following: CREATE TABLE Base ( ID int, Type varchar(20), Col1 varchar(255), Col2 varchar(255), AddedAt datetime2 ); CREATE TABLE Sub1 ( ...
user avatar
0 votes
1 answer
36 views

Postgres natively partitioned tables - adding extra child columns

With Postgres native partitioning, can you add extra columns to a partition of the base table? Like: CREATE TABLE item ( tenant_id bigint NOT NULL, item_id bigint NOT NULL, kind text NOT ...
user avatar
  • 139
1 vote
2 answers
501 views

Deleting rows from child table without deleting from parent [closed]

I have 2 tables, connected with inheritance. I want to delete some rows from the child table. The deletion part works but it deletes rows from the parent as well: CREATE OR REPLACE FUNCTION ...
user avatar
0 votes
2 answers
60 views

Why does selecting an attribute of an Oracle object require an alias?

My GIS software has an Oracle 18c object type called ST_GEOMETRY. The object type has attributes: The attributes of the spatial type represent the following information: Entity: The type of ...
user avatar
  • 1,377
1 vote
2 answers
216 views

Oracle MV requires object type to be defined as FINAL?

I want to create an Oracle 18c materialized view (MV) on a table that has a user-defined datatype called ST_GEOMETRY: The MV would do a COMPLETE refresh on a schedule — on a local table. Some info ...
user avatar
  • 1,377
0 votes
0 answers
82 views

How to model inheritance in MySQL for adding and deleting users?

I currently have a MySQL database and our ERD has inheritance for various tables. One is User which has as children: administrators, students and professors. The tables look as follow: CREATE TABLE `...
user avatar
0 votes
1 answer
129 views

Modeling Table-Per-Type in PostgreSQL

I have read the following post How do you effectively model inheritance in a database? about inheritance in databases. Unfortunately I could not find anything in the PostgreSQL books from Packt. And ...
user avatar
  • 123
0 votes
1 answer
69 views

When using class inheritance, can all PKs of the derived tables exist as PKs of the base table?

Brief questions When class inheritance is used, the child table inherits the key from the parent, right? Thus, you INSERT INTO the parent and then the child? This indicates that the PK of the child ...
user avatar
  • 1
0 votes
0 answers
36 views

Poor performance in a SELECT using Inheritance

I will detail my problem in good detail. I have a marketplace application so I make a decision to make a multitenant per schema approach. I like this approach because of the isolation of data, but I'm ...
user avatar
  • 101
0 votes
1 answer
723 views

Postgres role does not inherit permissions from its member role

I want to group my postgres database permissions to set of roles and then assign users to these parent roles to manage all permissions from a central place. I created a role called admins and granted ...
user avatar
0 votes
1 answer
118 views

Inheritence and Primary Key Constraints

I am currently trying to see how the object oriented features come in play in Postgres. During a few tests I noticed that when you insert in or delete from inheriting tables that those changes also ...
user avatar
1 vote
1 answer
346 views

Improve PostgreSQL SELECT performance in a parent table (inheritance)

I have a PostgreSQL 9.2 database where each account has a schema, like below: My_Database |-> Schemas |-> AccountA |-> AccountB |-> AccountC |-> AccountD |-> ...
user avatar
0 votes
1 answer
57 views

PostgreSQL 10.6: Alter parent table will block ALL children?

I want to add a column to near 74.000 child tables. These tables continually have insertions and reads from all the services in the company, in almost realtime. If I add a column to the parent table, ...
user avatar
0 votes
0 answers
31 views

I have multiple different objects which share most attributes, but vary on a few, what methods could I use to model them?

I have a few different items which mostly share the same attributes, but then have a few extra/less. In OOP they could be modeled well with inheritance, but postgres' inheritance is limiting and doesn'...
user avatar
  • 111
1 vote
1 answer
217 views

Can I improve the way pg_dump exports inherited tables?

Given a postgresql 12 database with some table inheritance, and the child table adds no additional columns: CREATE TABLE parent ( id integer NOT NULL PRIMARY KEY, name text NOT NULL ); ...
user avatar
0 votes
1 answer
39 views

Table Partitioning Using Inheritance and Triggers

I am trying to do table partitioning in PostgreSQL using inheritance and triggers but the problem that have occured to me is that the data does not move from the parent table to the children tables I ...
user avatar
  • 3
0 votes
1 answer
38 views

Pass information to another table with the same inherit

Suppose the following scenario ... I have two tables (A, B) that inherit from a Z table, the SGBD is postgresql, these tables do not have an additional column, my question is how to pass a row from ...
user avatar
6 votes
1 answer
5k views

What is the purpose of "Schema Owner"?

If I create a new schema and set the schema owner to another schema, for example dbo, what is the meaning of that in regards to my new schema? Does my new schema inherit the same permissions from it'...
user avatar
  • 24.3k
0 votes
1 answer
608 views

PostgreSQL Trigger to override insert on table with inheritance

We have a table documents that is partitioned by time into child tables like documents_2019_01, documents_2019_02. We do this using a BEFORE trigger on the parent documents table to insert into the ...
user avatar
  • 115
0 votes
1 answer
256 views

Progressive child tables scan in PostgreSQL?

We have append-only events table where events from different devices are being collected. We use PostgreSQL 9.6 and pg_partman to split the table into monthly partitions. Data is partitioned using ...
user avatar
0 votes
1 answer
41 views

make exist table as inherit

i try to create parent table for exists table, by next algorithm: -- CREATE TABLE CREATE TABLE t1 (id serial PRIMARY KEY); CREATE TABLE foreign_t1 (id serial, t1_id integer REFERENCES t1 (id)); -- ...
user avatar
2 votes
0 answers
94 views

Is it possible to drop inheritance from the parent table (top down)?

Our system uses inheritance on two levels: master child_level_1 child_level_2 child_level_2 child_level_2 child_level_1 child_level_2 child_level_2 child_level_1 child_level_2 The idea was to ...
user avatar
  • 121
5 votes
1 answer
2k views

Transfer row from 'parent' to 'child' without creating duplicate and without knowing all 'parent' columns

I want to set up a database with different schemas that correspond to different data-entry systems. There needs to be a “master” (administration) schema with a “parties” table, and multiple other ...
user avatar
2 votes
1 answer
171 views

Correct way to join row in parent table to row in one of several children tables

I have a parent table product, and several children tables like phone, tablet, smartwatch etc. The parent and children have 1-1 relationship. This means that for every row in parent table, there will ...
user avatar
1 vote
0 answers
688 views

Implementing a graph-like design on postgresql using CTEs and inheritance

This question is about attempting to model/design an elementary graph-like database within postgres. The starting point is that graphs have: Nodes Nodes have properties Node are connected by (bi/...
user avatar
  • 669
0 votes
1 answer
1k views

How to list all the inherited tables from the parent table?

I have 3 tables (janitor, security & manager) which inherited from the user table. What is the query can be used to produce the following result(list all the name of the child tables)? Thank you....
user avatar
  • 3
2 votes
0 answers
566 views

Is it correct to model a specialized table using a foreign key whose referencing attributes are not also forming its primary key?

In the process of designing a database model, I would like to implement a Class Table Inheritance pattern in a way that does not seem common at first. I would like to know if it is a correct ...
user avatar
  • 211
1 vote
1 answer
488 views

user security inheritance in SQL Server 2016

I'd like to build a bunch of new databases (several dozen) in SQL Server 2016. However, I'd like all users to access a single database (called SECURITY for now), and apply security to that one ...
user avatar
  • 1,995
2 votes
1 answer
721 views

Database relationship inheritance [closed]

I have a vehicle sales store. In my store I sale many kind of vehicles for example cars and boats. And I would like to keep track of the sales. My vehicles has some attributes as: Arrive on store ...
user avatar
  • 123
0 votes
1 answer
4k views

Inheritance and foreign keys in Postgres

This is about using inheritance and foreign keys in Postgresql databases. Consider the following simplistic example whose structure is based on what I am building at the moment (but the specifics were ...
user avatar
  • 669
1 vote
2 answers
952 views

Views that inherit a table and syntax in PostgreSQL

I am getting a syntax error but don't understand what is wrong. I am using a reference here. This is my sql-snippet: CREATE OR REPLACE VIEW stipa_test.stipa_view AS ( SELECT * FROM ... ...
user avatar
  • 139
2 votes
0 answers
211 views

PostgreSQL database re-design considerations

We have a 2TB PostgreSQL database, which contains two groups of tables that account for about 90% of the storage used. These two groups can be loosely described as 2 big tables partitioned, the first ...
user avatar
2 votes
1 answer
182 views

Designing an extensible authentication system

I need to design an authentication system, where different type of authentication schemes may exist. At the end, I should assign a passphrase (access token) to the user. I have several authentication ...
user avatar
2 votes
1 answer
269 views

Inheritance of "dictionary tables"

(In case this matters: I'm using SQLite) My silly little database has a surprising number of tables with identical structure: CREATE TABLE GTag ( ID INTEGER PRIMARY KEY NOT NULL, ...
user avatar
  • 23
0 votes
1 answer
174 views

Can Postgres inherited tables overlap

Is it possible to have single row in a parent table be visible in more than one inherited (child) table? Perhaps by inserting a row directly into the master table and then "making it visible" in one ...
user avatar
  • 573
5 votes
3 answers
7k views

Using table inheritance instead of mapping tables

This seems like a pretty common scenario: several types that all compose the same child type. This could typically look like so: -- 'name' is unique per parent record CREATE TABLE sometype ( ...
user avatar
  • 159
0 votes
1 answer
4k views

PostgreSQL: Multiple Inheritance tables (one child to two parents)

If I have a base table and 2 or more tables that inherit from it, child1 and child2, I can insert a record into a child table and it shows up in base as you would expect. However what I want to know ...
user avatar
4 votes
2 answers
3k views

Abstract classes in SQL Server. Are they even possible?

I have a very specific question that I am surprised no one has yet asked. It involves a concrete class model and SQL Server 2016 DDL. The main point is: In my model, some classes inherit from a base ...
user avatar
0 votes
1 answer
504 views

Django Multi Table Inheritance and Preserving Child and Child History

Place can have many different one to one fields, that’s why it can have bookstore, restaurant, and hardware store. But can the same place be both a bookstore and a restaurant at the same time? Now if ...
user avatar
1 vote
2 answers
346 views

DB model strategy to override field value

We have to store some dynamic configuration in JSON format in DB. There would be some default configuration, and it can be overriden per account. Can someone help me with the strategy to store such ...
user avatar
  • 121
2 votes
2 answers
3k views

Postgres inherit from one role and not another

I'm a little new with postgres but have a decent understanding of roles. What I have are users that inherit from their normal "data_analyst" group. This group is used to manage all data analyst users ...
user avatar
5 votes
1 answer
9k views

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 ...
user avatar
5 votes
2 answers
880 views

Postgresql inheritance based database design

I'm developing a simple babysitter application that has 2 types of users: a 'Parent' and the 'Babysitter'. I'm using postgresql as my database but I'm having trouble working out my database design. ...
user avatar
  • 153
0 votes
2 answers
915 views

Modeling a product database and dealing with inheritance

So, to get better at designing databases, I'm attempting to model a database system after the AR15 Builder. Here is what I have so far: While it makes sense logically, I'm afraid there may be ...
user avatar
0 votes
1 answer
322 views

Is it possible to set order in which inherited tables a scanned in postgresql?

I have a postgresql measurement table which is partitioned based on logdate column by month. Suppose I have city_id integer column and want to select latest row with city_id = 125. When I run explain ...
user avatar
  • 1
2 votes
1 answer
3k views

Postgres 9.5 foreign table inheritance not using indexes

In PostgreSQL 9.5.0 I have a partitioned table that collects data by months. I tried to use the new PostgreSQL feature of foreign table inheritance and pushed one month of data to another PostgreSQL ...
user avatar
2 votes
3 answers
488 views

Record inheritance in mySQL

I have been struggling with this for a little while. I want to have a set of calendar records. The top level will apply to a large group; the next level will apply to a sub-set and the final level ...
user avatar
  • 21
1 vote
0 answers
960 views

PostgreSQL doesn't use index on inherited tables

I have two tables in PostgreSQL 9.4.5 deployed on Amazon RDS: an append only, weekly partitioned, All Positions table. These store all position readings from about 100,000 sensors. There are about 50 ...
user avatar