Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

parent-child relation with two children...

 
   Database Help (Home) -> Technology and Theory RSS
Next:  SQL BEFORE puzzle  
Author Message
Daniel Pitts

External


Since: Nov 16, 2007
Posts: 7



(Msg. 1) Posted: Thu Jul 31, 2008 1:21 pm
Post subject: parent-child relation with two children...
Archived from groups: comp>databases>theory (more info?)

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/>

 >> Stay informed about: parent-child relation with two children... 
Back to top
Login to vote
-CELKO-

External


Since: Jan 31, 2008
Posts: 63



(Msg. 2) Posted: Sat Aug 02, 2008 7:44 am
Post subject: Re: parent-child relation with two children... [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I hope the real names are not as vague and "meta-data-ish" as
"Entities" and "id" in the real data. Being live and preview are
attributes, if I understand your intent. But Ia m not sure about the
key -- is it version_id or (version_id, version_type), so here is one
guess:

CREATE TABLE Entities
(version_id INTEGER NOT NULL PRIMARY KEY,
version_type CHAR(1) DEFAULT 'P' NOT NULL
CHECK (version_type IN ('P', 'L')),
parent_version_id INTEGER
REFERENCE Entities(version_id)); -- null is first prototype



> 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/>

 >> Stay informed about: parent-child relation with two children... 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Some really confusing things about parent-child relationship - hello I would really need some help with the following questions. And apologies for so many of them 1) a) In hierarchical model parent class can have several subclasses. What does that mean exactly? That an instance A of parent class can have..

Relation Definition - I'll try this another way (persistence is my middle name?). I use a precise definition of "relation" from mathematics. It is in the glossary mAsterdam collected that I sent out a few days ago. However, it seems that most folks here use so...

Functional Dependency to constrain a relation to exactly o.. - It's easy enough to describe a functional dependency that will constrain a relation to having at most one row; it is any functional dependency for which the determinant set is empty. In other words, for any relation R with set-of-attributes A, if you..

Cardinality of relation with empty set of attributes is 1 - Proof: MVFD with empty antecedent, for example {} -> {X} | {Y,Z} claims that cardinality of the XYZ relation is the product of cardinalities of its projection onto the sets X and YZ of attributes. Take {X} to be an empty set, then: {} -> {} | {X...

predicate, constraints, header, relvar, and relation - I've been reading a lot of CJ Date's work, and I have some fairly general (but fundamental) questions. Does a predicate apply to a relvar or a relation? It makes sense to me that you could have one relation that exists in two separate variables with two...
   Database Help (Home) -> Technology and Theory All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]