6 replaced http://stackoverflow.com/ with https://stackoverflow.com/
source | link

I have following class model that I'm quite happy with:

Class Model

A Whole has a special mandatory Part. Furthermore it has a collection of parts, that contains at least the mandatory part, but may contain many more. In the OO model parts don't need to know where they belong.

So now I came up with this RDB model:

Whole:
   id - primary key
   special_part_id - non-nullable, unique, foreign key to Part

Part:
   id - primary key
   whole_id - non-nullable, foreign key to Whole

The only constraint that is not checked here is Whole = Whole.special_mandatory_part.whole.

However, with this table layout I'm not even able to insert rows. Might be worth mentioning that I'm using an ORM, but even with plain SQL I would not know how to do it.

So my questions are:

  • Is this DB design bad, and if so why?
  • If not, how would you insert rows?
  • What design would you recommend and why?

I'm aware of this very similar question. However, because of the not null constraint my problem is slightly different (worse I'd say) and I'm not satisfied with the given answers.

UPDATE Just found an answer on how to insert rows with a table layout like thishow to insert rows with a table layout like this.

I have following class model that I'm quite happy with:

Class Model

A Whole has a special mandatory Part. Furthermore it has a collection of parts, that contains at least the mandatory part, but may contain many more. In the OO model parts don't need to know where they belong.

So now I came up with this RDB model:

Whole:
   id - primary key
   special_part_id - non-nullable, unique, foreign key to Part

Part:
   id - primary key
   whole_id - non-nullable, foreign key to Whole

The only constraint that is not checked here is Whole = Whole.special_mandatory_part.whole.

However, with this table layout I'm not even able to insert rows. Might be worth mentioning that I'm using an ORM, but even with plain SQL I would not know how to do it.

So my questions are:

  • Is this DB design bad, and if so why?
  • If not, how would you insert rows?
  • What design would you recommend and why?

I'm aware of this very similar question. However, because of the not null constraint my problem is slightly different (worse I'd say) and I'm not satisfied with the given answers.

UPDATE Just found an answer on how to insert rows with a table layout like this.

I have following class model that I'm quite happy with:

Class Model

A Whole has a special mandatory Part. Furthermore it has a collection of parts, that contains at least the mandatory part, but may contain many more. In the OO model parts don't need to know where they belong.

So now I came up with this RDB model:

Whole:
   id - primary key
   special_part_id - non-nullable, unique, foreign key to Part

Part:
   id - primary key
   whole_id - non-nullable, foreign key to Whole

The only constraint that is not checked here is Whole = Whole.special_mandatory_part.whole.

However, with this table layout I'm not even able to insert rows. Might be worth mentioning that I'm using an ORM, but even with plain SQL I would not know how to do it.

So my questions are:

  • Is this DB design bad, and if so why?
  • If not, how would you insert rows?
  • What design would you recommend and why?

I'm aware of this very similar question. However, because of the not null constraint my problem is slightly different (worse I'd say) and I'm not satisfied with the given answers.

UPDATE Just found an answer on how to insert rows with a table layout like this.

5 replaced http://programmers.stackexchange.com/ with https://softwareengineering.stackexchange.com/
source | link

I have following class model that I'm quite happy with:

Class Model

A Whole has a special mandatory Part. Furthermore it has a collection of parts, that contains at least the mandatory part, but may contain many more. In the OO model parts don't need to know where they belong.

So now I came up with this RDB model:

Whole:
   id - primary key
   special_part_id - non-nullable, unique, foreign key to Part

Part:
   id - primary key
   whole_id - non-nullable, foreign key to Whole

The only constraint that is not checked here is Whole = Whole.special_mandatory_part.whole.

However, with this table layout I'm not even able to insert rows. Might be worth mentioning that I'm using an ORM, but even with plain SQL I would not know how to do it.

So my questions are:

  • Is this DB design bad, and if so why?
  • If not, how would you insert rows?
  • What design would you recommend and why?

I'm aware of this very similar questionthis very similar question. However, because of the not null constraint my problem is slightly different (worse I'd say) and I'm not satisfied with the given answers.

UPDATE Just found an answer on how to insert rows with a table layout like this.

I have following class model that I'm quite happy with:

Class Model

A Whole has a special mandatory Part. Furthermore it has a collection of parts, that contains at least the mandatory part, but may contain many more. In the OO model parts don't need to know where they belong.

So now I came up with this RDB model:

Whole:
   id - primary key
   special_part_id - non-nullable, unique, foreign key to Part

Part:
   id - primary key
   whole_id - non-nullable, foreign key to Whole

The only constraint that is not checked here is Whole = Whole.special_mandatory_part.whole.

However, with this table layout I'm not even able to insert rows. Might be worth mentioning that I'm using an ORM, but even with plain SQL I would not know how to do it.

So my questions are:

  • Is this DB design bad, and if so why?
  • If not, how would you insert rows?
  • What design would you recommend and why?

I'm aware of this very similar question. However, because of the not null constraint my problem is slightly different (worse I'd say) and I'm not satisfied with the given answers.

UPDATE Just found an answer on how to insert rows with a table layout like this.

I have following class model that I'm quite happy with:

Class Model

A Whole has a special mandatory Part. Furthermore it has a collection of parts, that contains at least the mandatory part, but may contain many more. In the OO model parts don't need to know where they belong.

So now I came up with this RDB model:

Whole:
   id - primary key
   special_part_id - non-nullable, unique, foreign key to Part

Part:
   id - primary key
   whole_id - non-nullable, foreign key to Whole

The only constraint that is not checked here is Whole = Whole.special_mandatory_part.whole.

However, with this table layout I'm not even able to insert rows. Might be worth mentioning that I'm using an ORM, but even with plain SQL I would not know how to do it.

So my questions are:

  • Is this DB design bad, and if so why?
  • If not, how would you insert rows?
  • What design would you recommend and why?

I'm aware of this very similar question. However, because of the not null constraint my problem is slightly different (worse I'd say) and I'm not satisfied with the given answers.

UPDATE Just found an answer on how to insert rows with a table layout like this.

4 added 89 characters in body
source | link

I have following class model that I'm quite happy with:

Class Model

A Whole has a special mandatory Part that has to be present always. Furthermore it has a collection of parts, that contains at least the mandatory part, but may contain many more. In the OO-Model model parts don't need to know where they belong.

So now I came up with this RDB-Model model:

Whole:
   id - primary key
   special_part_id - non-nullable, unique, foreign key to Part

Part:
   id - primary key
   whole_id - non-nullable, foreign key to Whole

The only constraint that is not checked here is Whole = Whole.special_mandatory_part.whole.

However, with this table layout I'm not even able to insert rows. Might be worth mentioning that I'm using an ORM, but even with plain SQL I would not know how to do it.

So my questions are:

  • Is thethis DB model just wrongdesign bad, and if so why?
  • If not, how would you insert rows?
  • What design would be a better modelyou recommend and why?

I'm aware of this very similar question. However, because of the not null constraint my problem is slightly different (worse I'd say) and I'm not satisfied with the given answers.

UPDATE Just found an answer on how to insert rows with a table layout like this.

I have following class model that I'm quite happy with:

Class Model

A Whole has a special mandatory Part that has to be present always. Furthermore it has a collection of parts, that contains at least the mandatory part, but may contain many more. In the OO-Model parts don't need to know where they belong.

So now I came up with this RDB-Model:

Whole:
   id - primary key
   special_part_id - non-nullable, unique, foreign key to Part

Part:
   id - primary key
   whole_id - non-nullable, foreign key to Whole

However, with this table layout I'm not even able to insert rows. Might be worth mentioning that I'm using an ORM, but even with plain SQL I would not know how to do it.

So my questions are:

  • Is the DB model just wrong?
  • If not, how would you insert rows?
  • What would be a better model?

I'm aware of this very similar question. However, because of the not null constraint my problem is slightly different (worse I'd say) and I'm not satisfied with the given answers.

UPDATE Just found an answer on how to insert rows with a table layout like this.

I have following class model that I'm quite happy with:

Class Model

A Whole has a special mandatory Part. Furthermore it has a collection of parts, that contains at least the mandatory part, but may contain many more. In the OO model parts don't need to know where they belong.

So now I came up with this RDB model:

Whole:
   id - primary key
   special_part_id - non-nullable, unique, foreign key to Part

Part:
   id - primary key
   whole_id - non-nullable, foreign key to Whole

The only constraint that is not checked here is Whole = Whole.special_mandatory_part.whole.

However, with this table layout I'm not even able to insert rows. Might be worth mentioning that I'm using an ORM, but even with plain SQL I would not know how to do it.

So my questions are:

  • Is this DB design bad, and if so why?
  • If not, how would you insert rows?
  • What design would you recommend and why?

I'm aware of this very similar question. However, because of the not null constraint my problem is slightly different (worse I'd say) and I'm not satisfied with the given answers.

UPDATE Just found an answer on how to insert rows with a table layout like this.

    Tweeted twitter.com/#!/StackProgrammer/status/487289202607149056
3 added 155 characters in body
source | link
2 added 1 character in body
source | link
1
source | link