Little help with normalisation...

Reply

Join Date: Mar 2008
Posts: 17
Reputation: Trogan is an unknown quantity at this point 
Solved Threads: 0
Trogan Trogan is offline Offline
Newbie Poster

Little help with normalisation...

 
0
  #1
Apr 19th, 2009
Hi,

I need some help with normalisation please. I need to enter an event multiple times using the same event number under the "supply" table, however I receive the "unique constraint violated" error.

I have attached my normalisation up to 3NF, but believe I have messed up somewhere.

I'd appreciate any help/explanation on what I need to do as I am really stuck.

Thanks.
Last edited by Trogan; Apr 19th, 2009 at 5:44 pm.
Attached Files
File Type: doc Normalisation.doc (30.0 KB, 7 views)
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 306
Reputation: timothybard is an unknown quantity at this point 
Solved Threads: 26
timothybard's Avatar
timothybard timothybard is offline Offline
Posting Whiz

Re: Little help with normalisation...

 
1
  #2
Apr 19th, 2009
You need a Supply ID primary key in the Supply table with event no and wedding no as foreign keys. The way you have it set up currently, each event/wedding can have only one supply (I'm assuming the underlines indicate primary keys).
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 17
Reputation: Trogan is an unknown quantity at this point 
Solved Threads: 0
Trogan Trogan is offline Offline
Newbie Poster

Re: Little help with normalisation...

 
0
  #3
Apr 19th, 2009
Hi Timothy,

Thanks for your reply. I did what you said and I can now enter multiple events with the same event number - thanks.

I do have one more question: the tables I am normalizing do not include any SupplyID or SupplyNo. In cases like these, would I automatically create a SupplyID or SupplyNo to make the table unique? What about having a composite key?

Could you explain this to me briefly please? Thanks again.

I'm assuming the underlines indicate primary keys
Yes and foreign keys.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 306
Reputation: timothybard is an unknown quantity at this point 
Solved Threads: 26
timothybard's Avatar
timothybard timothybard is offline Offline
Posting Whiz

Re: Little help with normalisation...

 
0
  #4
Apr 19th, 2009
The particulars will always be determined by your database needs, however, it is rather common for each different table to have its own ID, which is the primary key for the table. If a table has a primary key, then no two records can have the same value as the primary key. The primary key is simply a way to ensure that all records are unique.

It is common to have the database management system, such as MS Access, MS SQL Server, mySQL, etc. generate the primary key. It is usually just a sequential sequence of integers (1, 2, 3, 4, etc). You just need to make sure to tell the database management system which field is the primary key and it takes care of generating the values.

It is possible to use composite keys, but it would not work in your situation with the supply table because there is a one-to-many relationship between supply table and the event table. Secondly, there is a direct relationship between the event table and the wedding table, so using the wedding id as part of the composite key does not help to make the key unique. A composite key would be more appropriate in a situation where there are two one-to-many relationships from one table to two or more separate tables and there is only one record that is associated for any two particular records. The composite keys you have in the Event_Guest and Event_Venue tables are good uses of composite keys.
Last edited by timothybard; Apr 19th, 2009 at 11:29 pm.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 17
Reputation: Trogan is an unknown quantity at this point 
Solved Threads: 0
Trogan Trogan is offline Offline
Newbie Poster

Re: Little help with normalisation...

 
0
  #5
Apr 20th, 2009
Thank you for the detailed explanation.

One last question, if you don't mind: I have created the composite keys for the Event_Guest and Event_Venue. However, is it necessary to create an Event_Supply table? If I was to create one, would a composite key work bearing in mind the Supply table has 1 PK and 2FK's?

Thanks again.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 306
Reputation: timothybard is an unknown quantity at this point 
Solved Threads: 26
timothybard's Avatar
timothybard timothybard is offline Offline
Posting Whiz

Re: Little help with normalisation...

 
0
  #6
Apr 20th, 2009
It appears that there is a many-to-many relationship between the supplies and events (each event can have more than one supply and each supply can be used for more than one event). If that is the case, then an Event_Supply table would be appropriate. The Event_Supply table would have a composite key of event_no and supply_no. The supply table would not have a composite key and would have a primary key of only supply_no and would not need any foreign keys. Having the foreign keys would mean that each supply could only be used for one event.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Database Design Forum


Views: 602 | Replies: 5
Thread Tools Search this Thread



Tag cloud for Database Design
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC