943,526 Members | Top Members by Rank

Ad:
Apr 19th, 2009
0

Little help with normalisation...

Expand Post »
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.
Attached Files
File Type: doc Normalisation.doc (30.0 KB, 37 views)
Last edited by Trogan; Apr 19th, 2009 at 5:44 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Trogan is offline Offline
25 posts
since Mar 2008
Apr 19th, 2009
1

Re: Little help with normalisation...

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).
Reputation Points: 27
Solved Threads: 29
Posting Whiz
timothybard is offline Offline
317 posts
since Mar 2007
Apr 19th, 2009
0

Re: Little help with normalisation...

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.

Quote ...
I'm assuming the underlines indicate primary keys
Yes and foreign keys.
Reputation Points: 10
Solved Threads: 0
Light Poster
Trogan is offline Offline
25 posts
since Mar 2008
Apr 19th, 2009
0

Re: Little help with normalisation...

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.
Reputation Points: 27
Solved Threads: 29
Posting Whiz
timothybard is offline Offline
317 posts
since Mar 2007
Apr 20th, 2009
0

Re: Little help with normalisation...

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.
Reputation Points: 10
Solved Threads: 0
Light Poster
Trogan is offline Offline
25 posts
since Mar 2008
Apr 20th, 2009
0

Re: Little help with normalisation...

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.
Reputation Points: 27
Solved Threads: 29
Posting Whiz
timothybard is offline Offline
317 posts
since Mar 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Database Design Forum Timeline: Best Free Web-based Database
Next Thread in Database Design Forum Timeline: Database railway reservation system





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC