Results 1 to 3 of 3

Thread: weak entities

  1. #1
    Join Date
    Jul 2009
    Posts
    4

    Unanswered: weak entities

    Can anyone tell me whats the advantage of using weak entities, is it a principle to get the data structure more close to the reality? there are performance gains at some level when using it?

    I understand the concept but I was wondering whats the advantage of using it besides more id space related to the primary key depending on other table's primary key?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by davexpt
    I understand the concept but I was wondering whats the advantage of using it besides more id space related to the primary key depending on other table's primary key?
    the advantage is that a weak entity uses a foreign key to another entity as part of its own primary key

    it has nothing to do with space and everything to do with accurately modelling the data
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jul 2009
    Posts
    4
    hmm I see, so it is a questio of modeling after all, ok thanks for your answer, apreciated ^^

    by the way, if I want to use one weak entity say companies & products

    and the product goes something like

    create table product(
    `id` int(11) UNSIGNED NOT NULL,
    `company_id int (11) UNSIGNED NOT NULL,
    ....
    PRIMARY KEY( `id`, `company_id`)
    ...
    whats the correct way of doing this, with auto_increment on the id ?

    I was wondering if it is possible to have something like:
    company 1 product 1 /
    company 2 product 1
    company 1 product 2
    ...
    etc
    (only incrementing within the same company automatically)
    is it possible or is not a good practice?
    Last edited by davexpt; 08-15-09 at 09:04.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •