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  dBforums > Database Server Software > MySQL > weak entities

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-13-09, 07:22
davexpt davexpt is offline
Registered User
 
Join Date: Jul 2009
Posts: 4
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?
Reply With Quote
  #2 (permalink)  
Old 08-13-09, 07:45
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 08-15-09, 07:47
davexpt davexpt is offline
Registered User
 
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 08:04.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On