If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > HELP - Challenging Data Modeling Problem!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-26-04, 09:56
Matt_T_hat Matt_T_hat is offline
Registered User
 
Join Date: Sep 2003
Location: UK
Posts: 122
HELP - Challenging Data Modeling Problem!

I have been given the task of creating a fairly well normailized relational database. [Products] is our main table. The other is [Price_Band] and allows a number of name bands to be invented now the difficult bit. I need have the database hold priceband information for every price band for every product. If a new product is invented it should have the [Price_Band] defaults and if a new Price Band is added then all products should have the default settings.

So how do I create a normal for this mess? I need a working ERD that I can impliment fairly swiftly.

Any ideas?
__________________
Matt the Hat says: "what!?"
A child of five could understand this! Fetch me a child of five!
SCARY HARD CHALLENGE: http://www.dbforums.com/database-concepts-design/988682-better-relational-design.html
Reply With Quote
  #2 (permalink)  
Old 01-26-04, 10:02
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
product -----------<- prodpriceband ->----------- priceband

a typical many-to-many relationship

the business about new products getting default bands and new bands being added to every product, well, that's all done with application logic


__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 01-26-04, 10:11
Matt_T_hat Matt_T_hat is offline
Registered User
 
Join Date: Sep 2003
Location: UK
Posts: 122
So what your saying is that

For Each [Product] do.sql(For Each [Band] make table)

or some such...

Darn

What would the SQL look like for ensureing no duplicates of a band for a product and checking for the absence of said bands?
__________________
Matt the Hat says: "what!?"
A child of five could understand this! Fetch me a child of five!
SCARY HARD CHALLENGE: http://www.dbforums.com/showthread.php?threadid=988682
Reply With Quote
  #4 (permalink)  
Old 01-26-04, 10:13
Matt_T_hat Matt_T_hat is offline
Registered User
 
Join Date: Sep 2003
Location: UK
Posts: 122
Can a Query not be made like:

Select * from bands unless same exists in exeptions table?
__________________
Matt the Hat says: "what!?"
A child of five could understand this! Fetch me a child of five!
SCARY HARD CHALLENGE: http://www.dbforums.com/showthread.php?threadid=988682
Reply With Quote
  #5 (permalink)  
Old 01-26-04, 10:17
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
to ensure no duplicates, declare a unique constraint

in the case of the prodpriceband table, the primary key will suffice, since it is unique

create table prodpriceband
( prodid integer not null
, pricebandid integer not null
, primary key (prodid,pricebandid)
, constraint p_fk foreign key (prodid) references product(id)
, constraint pb_fk foreign key (pricebandid) references priceband (id)
)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 01-26-04, 10:30
Matt_T_hat Matt_T_hat is offline
Registered User
 
Join Date: Sep 2003
Location: UK
Posts: 122
Thankyou that might just work...

I'm not sure how easy this will be as that'll be a first for a primary key I'm useing...

Thanks again

-Matt
__________________
Matt the Hat says: "what!?"
A child of five could understand this! Fetch me a child of five!
SCARY HARD CHALLENGE: http://www.dbforums.com/showthread.php?threadid=988682
Reply With Quote
  #7 (permalink)  
Old 01-26-04, 10:32
Matt_T_hat Matt_T_hat is offline
Registered User
 
Join Date: Sep 2003
Location: UK
Posts: 122
The real beast is that I have to do this in Access 2000...

Anyone have thoughts on the combined key?
__________________
Matt the Hat says: "what!?"
A child of five could understand this! Fetch me a child of five!
SCARY HARD CHALLENGE: http://www.dbforums.com/showthread.php?threadid=988682
Reply With Quote
  #8 (permalink)  
Old 01-26-04, 10:48
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
thoughts on the combined key?

there can be only one thought: that is the right way to do it

did you have a specific concern?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #9 (permalink)  
Old 01-26-04, 10:51
Matt_T_hat Matt_T_hat is offline
Registered User
 
Join Date: Sep 2003
Location: UK
Posts: 122
Yes, sorry...

Specific concern: how the heck to talk an MS-Access database into doing that.. if it can be done with one at all.

Should have made myself clear to start with.

Thanks for advice it makes a lot of sence.

EDIT: Hmm I see, I have now created said table... not so hard really. The question that troubles me is how do I treat this table when creating queries?
__________________
Matt the Hat says: "what!?"
A child of five could understand this! Fetch me a child of five!
SCARY HARD CHALLENGE: http://www.dbforums.com/showthread.php?threadid=988682

Last edited by Matt_T_hat; 01-26-04 at 11:01.
Reply With Quote
  #10 (permalink)  
Old 01-26-04, 12:44
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
if you have access to (no pun intended) the MDB file, just open it, open the table in Design view, highlight both columns, and click on the little key -- this makes them a composite primary key

if you do not have access to the MDB, you will have to talk to it using DDL -- see Common DDL SQL for the Microsoft Access Database Engine

as for your other question, "how do I treat this table when creating queries?", i am afraid you will have to be more specific, i don't know what you mean by "treat"
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #11 (permalink)  
Old 01-26-04, 13:13
Matt_T_hat Matt_T_hat is offline
Registered User
 
Join Date: Sep 2003
Location: UK
Posts: 122
I think I was worrying too much my friend.

Thankyou for your help it has been greatly apreciated.
__________________
Matt the Hat says: "what!?"
A child of five could understand this! Fetch me a child of five!
SCARY HARD CHALLENGE: http://www.dbforums.com/showthread.php?threadid=988682
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On