double primary/unique, how to autoincrement one based on the other.
Sorry if the title of this post is a bit confusing as that what I am, confused.
I have the following situation
I have a list of events which are broken into those generated by different components. The EventID is unique for each component (I have these generated as unique and primary).
|EventID |ComponentID | Description |
|1 |1 | blah |
|1 |2 | de |
|2 |1 | blah |
Now what I want to be able to do is add a new event, I want the page to display the number of the event being added (ie the next number in the autoincrement). This has to take into the account of the ComponentID, that is (based on the table above) if I were to add a Component 1 event it would have EventId 3 but if I were to add a Component 2 event it would have EventId 2..
I'm not sure how to implement this as I'm a total Database novice.. if all else fails I'm tempted to have a table for each component but this would make adding new Components messy.
Any help greatly appreciated.