Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > General > Database Concepts & Design > Schema for Company database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-06-08, 15:32
mikr mikr is offline
Registered User
 
Join Date: Jul 2008
Posts: 2
Schema for Company database

Hi all,
I am new here and also newbie to databases.

I am trying to create a database that will hold information about who owns a company. Something like this:

A company can be own by one or more persons or other companies. Ex.
Google is owned by:
Person1
Person2
Company1
Company2

Futhermore I would like to keep track of the history, how the ownership change over time.

How can this be done?
Reply With Quote
  #2 (permalink)  
Old 07-06-08, 15:51
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,539
2 googles 4 u 2 do: party datamodel and supertype/subtype
__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon
Reply With Quote
  #3 (permalink)  
Old 07-06-08, 15:55
dportas dportas is offline
Registered User
 
Join Date: Dec 2007
Location: London, UK
Posts: 148
One possibility:

CREATE TABLE CompanyOwners_People
(CompanyId INT NOT NULL REFERENCES Companies (CompanyId),
Owner_PersonId INT NOT NULL REFERENCES People (PersonId));

CREATE TABLE CompanyOwners_Companies
(CompanyId INT NOT NULL REFERENCES Companies (CompanyId),
Owner_CompanyId INT NOT NULL REFERENCES Companies (CompanyId));
Reply With Quote
  #4 (permalink)  
Old 07-06-08, 15:56
dportas dportas is offline
Registered User
 
Join Date: Dec 2007
Location: London, UK
Posts: 148
Oops. Just in case it wasn't obvious:

CREATE TABLE CompanyOwners_People
(CompanyId INT NOT NULL REFERENCES Companies (CompanyId),
Owner_PersonId INT NOT NULL REFERENCES People (PersonId),
PRIMARY KEY (CompanyId, Owner_PersonId));

CREATE TABLE CompanyOwners_Companies
(CompanyId INT NOT NULL REFERENCES Companies (CompanyId),
Owner_CompanyId INT NOT NULL REFERENCES Companies (CompanyId)
PRIMARY KEY (CompanyId, Owner_CompanyId));
Reply With Quote
  #5 (permalink)  
Old 07-06-08, 18:54
mikr mikr is offline
Registered User
 
Join Date: Jul 2008
Posts: 2
This seems to work fine. Thank you. I did a quick try on OpenOffice - Base but it seems that the program does not like the double relation between "CompanyOwners_Companies" and "Companies". It allows me to define it but when I save it and reopen it's gone. Is this the normal behavior for this program or am I doing something wrong.
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

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