A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

inheritance



 
 
Thread Tools Display Modes
  #1  
Old March 28th, 2009, 11:55 AM posted to microsoft.public.access.tablesdbdesign
Geo
external usenet poster
 
Posts: 82
Default inheritance

I have one supper class table called sample and some subclasses called DNA ,
RNA etc. which inherite from Sample table. In sample table I have SampleId
(PK) and sampletype to show whether its RNA or DNA etc. But if i have to
query on the basis of sampleID to get all information about that, then How
can i know in which subtable it is? In my case i have to join all subclass in
all case to get the ans.

Any other option like a subquery which gives the sampletype from sample
table by taking sampleID and then i should forward the main query to that
particular subtable?

  #2  
Old March 28th, 2009, 12:38 PM posted to microsoft.public.access.tablesdbdesign
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default inheritance

hi Geo,

Geo wrote:
I have one supper class table called sample and some subclasses called DNA ,
RNA etc. which inherite from Sample table.

Super and sub classes in databases theory may give you this table layout:

Sample: ID, Discriminator, common fields

with e.g. Discriminator Text(3) containing either DNA or RNA.

Sample_DNA: idSample, DNA specific fields
Sample_RNA: idSample, RNA specific fields

One problem with super and sub classes is that you cannot ensure
referential integrity on declarative level only. Normally you would use
a trigger/stored procedure solution the enforce RI.

In sample table I have SampleId
(PK) and sampletype to show whether its RNA or DNA etc. But if i have to
query on the basis of sampleID to get all information about that, then How
can i know in which subtable it is?

You normally would use an extra discriminator in the table derived from
the super class.

In my case i have to join all subclass in all case to get the ans.

In Access you could use DCount() to get an updateable query:

SELECT *,
DCount("*", "Sample_DNA", "idSample = " & ID) AS isDNA,
DCount("*", "Sample_RNA", "idSample = " & ID) AS isRNA
FROM Sample

For performance reasons you should use a discriminator.


btw, you may have a look at the EAV model:

http://en.wikipedia.org/wiki/Entity-...te-value_model

depending on the field types and their distribution between super and
sub classes this may be also a solution.


mfG
-- stefan --
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:25 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.