Questions tagged [inheritance]

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

For example, contractors, full time and tenured employees may have some attributes in common and also some attributes that apply only to themselves. An implementation would to have a base Employees type to implement the common attributes, and separate Contractor, Fulltime and Tenured types that inherit from Employee but implement the type-specific attributes.

90 questions
11
votes
5 answers

Insert into select into multiple related tables using INSERT_IDENTITY

Okay setting the scene. I have three tables, (Table1, Table2 and DataTable) and I want to insert into Table1 and Table2 using DataTable as source. So for every row in DataTable I want a row in Table1 and Table2, and Table2 needs to have the inserted…
m4rc
  • 235
  • 1
  • 2
  • 7
11
votes
2 answers

Conceptual ERD Multi-table many to many, or possibly recursive?

I'm creating a conceptual diagram [yes, I know I've included attributes and keys - but this is just for me to consolidate what I'm doing whilst learning] -- so please treat it as Conceptual with the focus on Relationships and tables and not how to…
MVC Newbie
  • 213
  • 2
  • 6
9
votes
1 answer

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's owner dbo?
J.D.
  • 40,776
  • 12
  • 62
  • 141
8
votes
2 answers

Partial unique constraint spanning multiple tables in postgres

To enforce partial uniqueness in postgres, it is a well known workaround to create a partial unique index instead of an explicit constraint, like so: CREATE TABLE possession ( possession_id serial PRIMARY KEY, owner_id integer NOT NULL…
lpd
  • 251
  • 1
  • 2
  • 7
8
votes
2 answers

Polymorphic Association - is it bad?

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, ReportId, or ReviewId. There will also be an…
7
votes
2 answers

Query parent table and get child tables columns

I have two tables, one inherits the other: CREATE TABLE parent ( col1 INTEGER ); CREATE TABLE child ( col2 INTEGER ) INHERITS( parent ); // Insert some data INSERT INTO parent( col1 ) VALUES( 1 ); INSERT INTO child( col1, col2 ) VALUES( 2,…
frenchie4111
  • 173
  • 1
  • 1
  • 3
7
votes
2 answers

How to drop inheritance?

I am new to PostgreSQL. The situation I have is someone created a child table inherits from the parent table. And dropped the child table. But the parent table still has the "down arrow" sign on it. I checked and there's no other link/relation on…
user2486675
  • 81
  • 1
  • 1
  • 2
7
votes
1 answer

Performance issues with inherited tables and indices

I have a PostgreSQL database with a master table and 2 child tables. My master table: CREATE TABLE test ( id serial PRIMARY KEY, date timestamp without time zone ); CREATE INDEX ON test(date); My child tables: CREATE TABLE test_20150812…
7
votes
1 answer

PostgreSQL and table inheritance

I'm not sure if this is the right place for this, so please feel free to tell me if it is off-topic or there is a better place to post. I am working on a fantasy sports based project, and the number of tables is getting unruly. I have tables like…
6
votes
2 answers

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 to a company. A company can have loans and a…
ratherBeKiting
  • 63
  • 1
  • 1
  • 5
6
votes
1 answer

Index is not used with table inheritance

I have a PostgreSQL 9.0.12 database with a master table and 2 child tables. My tables: CREATE TABLE test2 ( id serial PRIMARY KEY, coll character varying(15), ts timestamp without time zone ); CREATE INDEX ON test2(ts); CREATE TABLE…
umut
  • 285
  • 3
  • 7
5
votes
1 answer

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 schemas with their own “parties” tables that inherit…
user2437443
  • 143
  • 1
  • 11
5
votes
3 answers

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 ( sometype_id serial PRIMARY KEY, name …
Dmitri
  • 159
  • 1
  • 4
5
votes
2 answers

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. The 'Parent' and the 'Babysitter' entities have…
Jdruwe
  • 153
  • 4
4
votes
1 answer

Enhanced ER Model Supertype / Subtype modeling issue with inheritance and recursion

Before posting, I have looked for a good solution on internet and I have coined this post for 3 days in row and trying to think through it prior this post. So if I have missed something or got it wrong, please, have understanding. I need to model…
1
2 3 4 5 6