•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Database Design section within the Web Development category of DaniWeb, a massive community of 397,859 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,387 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Database Design advertiser:
Views: 453 | Replies: 2
•
•
Join Date: Feb 2008
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
I have a database with let's say two tables as follows:
Products Table
ProductID | ProductName
and
Widgets Table
WidgetID | ProductID (Foreign Key) | Position
Now how do I set it up if I want a variable number of widgets that attach to a product. But I want to ensure uniqueness in the Position Column WHERE ProductID is XYZ.
So I want to be able to have the following entries in Widgets:
0 | 1 | 1
1 | 1 | 2
2 | 2 | 1
3 | 1 | 3
But not:
0 | 1 | 1
1 | 1 | 2
2 | 1 | 1
3 | 1 | 3
I'm using MySQL but I'm open to other databases. Or do I just need to handle this on the application side to check for a previous entry. I don't mind doing this either, but if there is a way to ensure that no duplicates get entered at all costs would be idea.
Thanks!
Gavin
Products Table
ProductID | ProductName
and
Widgets Table
WidgetID | ProductID (Foreign Key) | Position
Now how do I set it up if I want a variable number of widgets that attach to a product. But I want to ensure uniqueness in the Position Column WHERE ProductID is XYZ.
So I want to be able to have the following entries in Widgets:
0 | 1 | 1
1 | 1 | 2
2 | 2 | 1
3 | 1 | 3
But not:
0 | 1 | 1
1 | 1 | 2
2 | 1 | 1
3 | 1 | 3
I'm using MySQL but I'm open to other databases. Or do I just need to handle this on the application side to check for a previous entry. I don't mind doing this either, but if there is a way to ensure that no duplicates get entered at all costs would be idea.
Thanks!
Gavin
Last edited by im.thatoneguy : Feb 8th, 2008 at 7:15 pm.
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Database Design Marketplace
- Previous Thread: Dbms
- Next Thread: DB project



Threaded Mode