View Single Post
  #4  
Old July 12th, 2004, 07:42 AM
tina
external usenet poster
 
Posts: n/a
Default Complicated Databse w/many relationships

btw, sorry for the double-spacing in the tables and multiple spaces between
paragraphs - makes it harder to read, i know! i didn't write the post that
way, must be some freaky thing that Outlook Express did to it.


"tina" wrote in message
...
well, i don't know if i'm the Tina you mentioned but here's my two cents
worth. right off the bat, i would get rid of the Lookup fields in the
tables. for an explanation of why, see the link below:

http://www.mvps.org/access/lookupfields.htm

another very helpful link when getting started is

http://www.mvps.org/access/tencommandments.htm

it's written tongue-in-cheek, but gives serious and very useful advice. as
always, i recommend that you look around in the mvps.org website; it's a
fantastic resource generated by some of the best Access developers in the
world, many of whom also donate time to the newsgroups, and it's free to
everyone.



i know zilch about the EP, and politics in general, so i had to guess

about
some things. in general, here's how I organize my data:

i start with the main subject, in this case *members* of the EP. anything
that the main subject has only one of, such as a name, goes in the main

data
table - in this case tblMembers.

anything that the main subject *may* have more than one of, goes in a

child
data table linked to the main table. the child data table contains data
about a certain subject - such as tblMemberAddresses. of course there may

be
multiple child data tables.

any descriptive or categorizing data that has standard values, goes in a
"supporting" (lookup) table - such as a table of Countries, a table of
Cities, etc. that supporting table is used to populate the particular

field
in the data table - such as Country, in tblMemberAddresses.

below is a possible table setup. you'll have to apply the guidelines above
to determine where i may have gone wrong due to not understanding various
terms used in your post.



tblMembers (data table)

MemberID (primary key)

FirstName

LastName

NationalParty

Position

Title

Constituency

(i assumed that national party is the political party of the country the
member is a citizen of, such as Democratic/Republican parties in the U.S.
if, instead, it has "standard" values, then I would use the primary key

from
a supporting table to populate the field as a foreign key.

also, if position and title have "standard" values, then i would use a
supporting table as described above. Note: i have no idea what
"constituency" refers to. if it is specific to an address, then move it to
tblMemberAddresses. if the member may have multiple constituencies, not
specific to an address, then make a separate table for constituencies,

with
a foreign key from tblMembers.)



tblMemberAddresses (data table; 1-n relationship with tblMembers)

MemAddID (primary key)

MemberID (foreign key from tblMembers)

Street

City (possibly a foreign key from a supporting table of cities)

Zip

CountryID (foreign key from tblCountries)

Region (possibly a foreign key from a supporting table of regions)



tblCountries (supporting table; 1-n relationship with tblMemberAddresses)

CountryID (primary key)

CountryName



tblAddressPhones (data table; 1-n relationship with tblMemberAddresses)

AddPhID (primary key)

MemAddID (foreign key from tblMemberAddresses)

PhoneTypeID (foreign key from tblPhoneTypes)

PhoneNumber (text field)

Comments

(usually, i use this table to list email addresses and websites, as well

as
phone numbers - since they're all "ways to contact the main subject". but

in
this case, you have multiple addresses. phone and fax numbers are probably
specific to each address, which is why i used the foreign key from
tblMemberAddresses, rather than the foreign key from tblMembers.

*but*, an email address might not be specific to a certain street address.
if each Member has only one email address, i would put it in tblMembers.

if
they may have many, that are not specific to a street address, i would

make
a separate table for email addresses, with a foreign key from tblMembers.

the same considerations apply to website URL.)



tblPhoneTypes (supporting table; 1-n relationship with tblAddressPhones)

PhoneTypeID (primary key)

PhoneTypeName

(names such as Phone, Fax, Cell, possibly Email and/or URL, etc.)



tblBodyTypes (supporting table; 1-n relationship with tblBodies)

BodyTypeID (primary key)

BodyTypeName

(names such as Committee, Delegation, Political Group, etc)



tblBodies (supporting table; 1-n relationship with tblMemberPositions)

BodyID (primary key)

BodyTypeID (foreign key from tblBodyTypes)

BodyName



tblPositions (supporting table; 1-n relationship with tblMemberPositions)

PositionID (primary key)

PositionName

(names such as Member, Substitute, Chairman, Vice-Chairman, etc)



tblMemberPositions (data table; 1-n relationship with tblMembers)

MemPosID (primary key)

MemberID (foreign key from tblMembers)

BodyID (foreign key from tblBodies)

PositionID (foreign key from tblPositions)



remember to *not* use Access reserved words as field names, such as Name,
Date, etc. and recommend you use only letters and underscores ( _ ) in

your
table/field names; you can use numbers if you must, but i try to avoid it.


hth


"Søren" wrote in message
...
Hi,

I've had a look around in some of the questions here and especially the

ones from Tina, Allan and Rebecca - but I'm a bit stuck; I need a little
sparring and couching! I am trying to create a database with a lot of
contact information for the 732 members of the European Parliament. Status
qou is:

I have 732 MEPs each with

- 3 addresses (2x offices in Brussels & Strasbourg and Home) including

street, city, ZIP, country, region, counstituency, phone and fax numbers,
office locations, e-mails, websites, position, title etc;
- Uptil 12 connections (memberships) split on max 3 EP-Committess AND

max
3 EP Delegation AND 3 other bodies in EP AND a political group in the EP

AND
their National Party AND, of course, the European Parliament itself.
- Each of these connections can have different types of connections

(positions) - or the same, e.g. a MEP is always a Member of the European
Parliament, and a member OR Chariman OR Vice-Chairman of a Political

Group;
the MEP is also always a Member/Subsitute/Chairman/Vice-Chairman of at

least
2-3 Committees AND 2-3 Delegations.

Example:

the MEP is Member of the European Parliament
Member of the Green Group
Chairman of the Environmental Committee
Member of the Transport Committee
Subsitute of the Energy Committee
Vice-Chairman of the Delegation A
Member of the Delegation B
Member of another body under the EU Instituion

My setup now is

1- a MEP table which include all fields i.d. fields that only belongs to

this table and lookup fields connected to other table.
2- tables for EU Instituion, EP Committee, EP Delegation, Other Body,

Home
Country, National Party, Political Group, Title, Position
3- two intermediate table called EP Committeeship (fields: MEP.MEPID &

EP
Committee.EPCommitteeID) and EP Delegationship (MEPID.MEPID & EP
Delegation.EPDelegationID) to create a Many-to-Many relationship; the
relationship is one-to-many from MEP to EP Committeeship and many-to-one
from EP Committeeship to EP Committee, which again have many-to-one to
Position
4- I have direct one-to-many connections between MEP and EU Instituion,

MEP and Home Country, MEP and Political Group, MEP and National Party

All are liked via numeric autonumber ID fields with unique values (and

fieldnames) in each table e.g. PositionID is key in Position and linked to

a
numeric field with the same name in all related tables, EPDelegationID is
key in EP Delegation etc.

I have made lookup fields in the MEP table that refers to all the tables

mentioned above under 2.

Could someone give me a guidance through the this hurricane of relations

and table?

Thanks very much in advance!


BR, Søren