Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subtyping database tables

I hear a lot about subtyping tables when designing a database, and I'm fully aware of the theory behind them. However, I have never actually seen table subtyping in action. How can you create subtypes of tables? I am using MS Access, and I'm looking for a way of doing it in SQL as well as through the GUI (Access 2003).

Cheers!

like image 511
Smashery Avatar asked Apr 15 '09 00:04

Smashery


People also ask

What is a subtype in database?

A subtype is a sub-grouping of the entities in an entity type that is meaningful to the organization and that shares common attributes or relationships distinct from other subgroups.

What is an example of subtype?

Subtypes are a subset of features in a feature class, or objects in a table, that share the same attributes. They are used as a method to categorize your data. For example, the streets in a city streets feature class could be categorized into three subtypes: local streets, collector streets, and arterial streets.

What is a subtype in SQL?

A subtype is a definition of a type based on a built-in type. Subtypes provide a layer of abstraction between variables and parameters and the data types that they use. This layer allows you to concentrate any changes to the data types in one location.

What kind of data would you store in an entity subtype?

The entity subtype will store the data that is specific to the entity; that is, attributes that are unique the subtype.


2 Answers

An easy example would be to have a Person table with a primary key and some columns in that table. Now you can create another table called Student that has a foreign key to the person table (its supertype). Now the student table has some columns which the supertype doesn't have like GPA, Major, etc. But the name, last name and such would be in the parent table. You can always access the student name back in the Person table through the foreign key in the Student table.

Anyways, just remember the following:

  • The hierarchy depicts relationship between supertypes and subtypes
  • Supertypes has common attributes
  • Subtypes have uniques attributes
like image 119
jasonco Avatar answered Nov 04 '22 02:11

jasonco


Subtypes of tables is a conceptual thing in EER diagrams. I haven't seen an RDBMS (excluding object-relational DBMSs) that supports it directly. They are usually implemented in either

  1. A set of nullable columns for each property of the subtype in a single table
  2. With a table for base type properties and some other tables with at most one row per base table that will contain subtype properties
like image 37
mmx Avatar answered Nov 04 '22 02:11

mmx