dbTalk Databases Forums  

parent-child relation with two children...

comp.databases.theory comp.databases.theory


Discuss parent-child relation with two children... in the comp.databases.theory forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Daniel Pitts
 
Posts: n/a

Default parent-child relation with two children... - 07-31-2008 , 03:21 PM






I have something like:
entity (id, live_version_id NULL, preview_version_id NULL)
version (id, parent_entity_id)

where version.parent_entity_id must be a valid entity.id, and that
entity must have the version.id in either live/preview version_id. Is
this a common set up? Does it make sense? Is there a way to express
this requirement at the DB level (I'm specifically using MySQL, but in
general I'd like to know)

Or, did I model my data in a bad way?

Thanks,
Daniel.
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

Reply With Quote
  #2  
Old   
tal_mcmahonAThotmail.com
 
Posts: n/a

Default Re: parent-child relation with two children... - 08-01-2008 , 03:35 PM






Hi,
If I read this correctly, your saying

you have an entity, The entity is either Live or Preview, and the
entity has versions.

I have seen this before, and I believe it is an error in your model.

what you really want here is the entity table and 2 extension tables
of entity one for Live and one for preview.

Like this

Entity(pk_entity),
EntityLiveVersionExtension(pk_entity,LiveVersionID ,version),
EntityPreviewVersionExtension(pk_entity,PreviewVer sionID,version),


All of them have the primary key of pk_Entity and the extensions are a
one --> zero or one relationships


This is one of the ways to handle Object Inheritance within a
relational database. I am guessing you have (or at least could have)
an entityBase and a PreviewENtity and a LiveEntity.

HTH

Tal




Reply With Quote
  #3  
Old   
tal_mcmahonAThotmail.com
 
Posts: n/a

Default Re: parent-child relation with two children... - 08-01-2008 , 03:35 PM



Hi,
If I read this correctly, your saying

you have an entity, The entity is either Live or Preview, and the
entity has versions.

I have seen this before, and I believe it is an error in your model.

what you really want here is the entity table and 2 extension tables
of entity one for Live and one for preview.

Like this

Entity(pk_entity),
EntityLiveVersionExtension(pk_entity,LiveVersionID ,version),
EntityPreviewVersionExtension(pk_entity,PreviewVer sionID,version),


All of them have the primary key of pk_Entity and the extensions are a
one --> zero or one relationships


This is one of the ways to handle Object Inheritance within a
relational database. I am guessing you have (or at least could have)
an entityBase and a PreviewENtity and a LiveEntity.

HTH

Tal




Reply With Quote
  #4  
Old   
tal_mcmahonAThotmail.com
 
Posts: n/a

Default Re: parent-child relation with two children... - 08-01-2008 , 03:35 PM



Hi,
If I read this correctly, your saying

you have an entity, The entity is either Live or Preview, and the
entity has versions.

I have seen this before, and I believe it is an error in your model.

what you really want here is the entity table and 2 extension tables
of entity one for Live and one for preview.

Like this

Entity(pk_entity),
EntityLiveVersionExtension(pk_entity,LiveVersionID ,version),
EntityPreviewVersionExtension(pk_entity,PreviewVer sionID,version),


All of them have the primary key of pk_Entity and the extensions are a
one --> zero or one relationships


This is one of the ways to handle Object Inheritance within a
relational database. I am guessing you have (or at least could have)
an entityBase and a PreviewENtity and a LiveEntity.

HTH

Tal




Reply With Quote
  #5  
Old   
tal_mcmahonAThotmail.com
 
Posts: n/a

Default Re: parent-child relation with two children... - 08-01-2008 , 03:35 PM



Hi,
If I read this correctly, your saying

you have an entity, The entity is either Live or Preview, and the
entity has versions.

I have seen this before, and I believe it is an error in your model.

what you really want here is the entity table and 2 extension tables
of entity one for Live and one for preview.

Like this

Entity(pk_entity),
EntityLiveVersionExtension(pk_entity,LiveVersionID ,version),
EntityPreviewVersionExtension(pk_entity,PreviewVer sionID,version),


All of them have the primary key of pk_Entity and the extensions are a
one --> zero or one relationships


This is one of the ways to handle Object Inheritance within a
relational database. I am guessing you have (or at least could have)
an entityBase and a PreviewENtity and a LiveEntity.

HTH

Tal




Reply With Quote
  #6  
Old   
tal_mcmahonAThotmail.com
 
Posts: n/a

Default Re: parent-child relation with two children... - 08-01-2008 , 03:35 PM



Hi,
If I read this correctly, your saying

you have an entity, The entity is either Live or Preview, and the
entity has versions.

I have seen this before, and I believe it is an error in your model.

what you really want here is the entity table and 2 extension tables
of entity one for Live and one for preview.

Like this

Entity(pk_entity),
EntityLiveVersionExtension(pk_entity,LiveVersionID ,version),
EntityPreviewVersionExtension(pk_entity,PreviewVer sionID,version),


All of them have the primary key of pk_Entity and the extensions are a
one --> zero or one relationships


This is one of the ways to handle Object Inheritance within a
relational database. I am guessing you have (or at least could have)
an entityBase and a PreviewENtity and a LiveEntity.

HTH

Tal




Reply With Quote
  #7  
Old   
tal_mcmahonAThotmail.com
 
Posts: n/a

Default Re: parent-child relation with two children... - 08-01-2008 , 03:35 PM



Hi,
If I read this correctly, your saying

you have an entity, The entity is either Live or Preview, and the
entity has versions.

I have seen this before, and I believe it is an error in your model.

what you really want here is the entity table and 2 extension tables
of entity one for Live and one for preview.

Like this

Entity(pk_entity),
EntityLiveVersionExtension(pk_entity,LiveVersionID ,version),
EntityPreviewVersionExtension(pk_entity,PreviewVer sionID,version),


All of them have the primary key of pk_Entity and the extensions are a
one --> zero or one relationships


This is one of the ways to handle Object Inheritance within a
relational database. I am guessing you have (or at least could have)
an entityBase and a PreviewENtity and a LiveEntity.

HTH

Tal




Reply With Quote
  #8  
Old   
tal_mcmahonAThotmail.com
 
Posts: n/a

Default Re: parent-child relation with two children... - 08-01-2008 , 03:35 PM



Hi,
If I read this correctly, your saying

you have an entity, The entity is either Live or Preview, and the
entity has versions.

I have seen this before, and I believe it is an error in your model.

what you really want here is the entity table and 2 extension tables
of entity one for Live and one for preview.

Like this

Entity(pk_entity),
EntityLiveVersionExtension(pk_entity,LiveVersionID ,version),
EntityPreviewVersionExtension(pk_entity,PreviewVer sionID,version),


All of them have the primary key of pk_Entity and the extensions are a
one --> zero or one relationships


This is one of the ways to handle Object Inheritance within a
relational database. I am guessing you have (or at least could have)
an entityBase and a PreviewENtity and a LiveEntity.

HTH

Tal




Reply With Quote
  #9  
Old   
tal_mcmahonAThotmail.com
 
Posts: n/a

Default Re: parent-child relation with two children... - 08-01-2008 , 03:35 PM



Hi,
If I read this correctly, your saying

you have an entity, The entity is either Live or Preview, and the
entity has versions.

I have seen this before, and I believe it is an error in your model.

what you really want here is the entity table and 2 extension tables
of entity one for Live and one for preview.

Like this

Entity(pk_entity),
EntityLiveVersionExtension(pk_entity,LiveVersionID ,version),
EntityPreviewVersionExtension(pk_entity,PreviewVer sionID,version),


All of them have the primary key of pk_Entity and the extensions are a
one --> zero or one relationships


This is one of the ways to handle Object Inheritance within a
relational database. I am guessing you have (or at least could have)
an entityBase and a PreviewENtity and a LiveEntity.

HTH

Tal




Reply With Quote
  #10  
Old   
tal_mcmahonAThotmail.com
 
Posts: n/a

Default Re: parent-child relation with two children... - 08-01-2008 , 03:35 PM



Hi,
If I read this correctly, your saying

you have an entity, The entity is either Live or Preview, and the
entity has versions.

I have seen this before, and I believe it is an error in your model.

what you really want here is the entity table and 2 extension tables
of entity one for Live and one for preview.

Like this

Entity(pk_entity),
EntityLiveVersionExtension(pk_entity,LiveVersionID ,version),
EntityPreviewVersionExtension(pk_entity,PreviewVer sionID,version),


All of them have the primary key of pk_Entity and the extensions are a
one --> zero or one relationships


This is one of the ways to handle Object Inheritance within a
relational database. I am guessing you have (or at least could have)
an entityBase and a PreviewENtity and a LiveEntity.

HTH

Tal




Reply With Quote
Reply




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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.