473,385 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Design database

mseo
181 100+
hi, everybody
I need to design database for export & import company
the first problem which I have met is:
I want to design the tables and make the relationships to make it like [u]more than one supplier and more than one price for the same product[/U
this the first problem
the second one: what about if I have seven suppliers and therefore 7 prices how can I select the 3 cheapiest price in the developing level
I will be so happy if I get any help
and thanks in advance for any help you may provide me
Jan 13 '10 #1

✓ answered by MMcCarthy

I wouldn't put the price in the product table. I would create a join table between supplier and product i.e. SupplierID and ProductID as the joint primary key in another table and add the price field to that table. See below for example with Suppier A having an id of 101 and Supplier B having an id of 102 and then product cheese having an id of 1.
Expand|Select|Wrap|Line Numbers
  1. tblSupplierByProduct
  2.  
  3. SupplierID   ProductID   Price
  4. 101               1        2.56
  5. 102               1        2.15
  6.  
This way you can represent both suppliers and their prices for the product cheese.

8 2807
MMcCarthy
14,534 Expert Mod 8TB
I suggest you read this article on Database Normalization and Table Structures. You will need to get a better understanding of how databases work. Then once you have your basic table structure in place post the structure and we will try to help you sort out any relationship problems you are having.
Jan 13 '10 #2
nico5038
3,080 Expert 2GB
Having multiple prices demands to have a "unique" field that separates them. Looks to me you need to have prices per supplier so the table will need at least:
SupplierID, ProductID and Price

In general Prices can differ over time so you might need to keep track of the price history and thus in need of a (start and end?) date.
As an alternative you could store the price in an invoice when created to keep another kind of history of prices. This depends on how the company handles price changes.

The three cheapest can be selected by a "SELECT TOP 3" query that's being sorted on an ascending price.

So something to start with and be sure you ask the company many questions about how there procedure for Orders and Invoices is organized.

Nic;o)
Jan 13 '10 #3
mseo
181 100+
thanks for the previous replies
the attached file is the design which I started with and I ask you for any adjustments to make it suitable for the Rule: More than one supplier with more than one price for the same product.
I designed tbl_tenders for make it as I need but I think with this design I would duplicate any record
for instance if the table contains three fields
supplier_ID Product_ID Unit Price
A Co. F 2 $
I need not to duplicate this record on the level of supplier_ID and Product_ID in any record Just I want to edit the price not to enter them again to make it easy to me
and as kind of request I want the design not to be complicated because I will make the developing phase on my own. and I want to develope this program without confronting a lot of error resulting from the designing of the database
thanks for any help you may provide me with
Jan 15 '10 #4
nico5038
3,080 Expert 2GB
the Rule: More than one supplier with more than one price for the same product.
This isn't precise enough defined.
When one supplier can have multiple prices for one product (e.g. different price lists), an additional key field will be needed. You could add a "PriceListStartdate" field in the tblTenders, but that will also require that the price is collected using a date...
The UnitPrice shouldn't be in tblProduct as it's aready in the tblTenders, just the unique identifier(s) of tblTenders needs to be stored when using the product in an Invoice or Order detail.
When you don't keep a history of prices in tblTenders (so no multiple prices for one product of one supplier) you'll need to store the UnitPrice in an order or invoice detail. When you keep multiple prices per product, than the order/invoice date will be required to get the proper UnitPrice.

Getting the idea ?

Nic;o)
Jan 16 '10 #5
mseo
181 100+
thanks for you reply
but I didn't mean more one supplier more than price for one product
I meant more than one supplier so more than price for one product
let's assume that the cheese is the product and there are more than one supplier for this kind of cheese and those suppliers have different prices for the product
that is what I meant
how can I make the design suitable for this without duplicating any record
thanks
Jan 16 '10 #6
MMcCarthy
14,534 Expert Mod 8TB
I wouldn't put the price in the product table. I would create a join table between supplier and product i.e. SupplierID and ProductID as the joint primary key in another table and add the price field to that table. See below for example with Suppier A having an id of 101 and Supplier B having an id of 102 and then product cheese having an id of 1.
Expand|Select|Wrap|Line Numbers
  1. tblSupplierByProduct
  2.  
  3. SupplierID   ProductID   Price
  4. 101               1        2.56
  5. 102               1        2.15
  6.  
This way you can represent both suppliers and their prices for the product cheese.
Jan 17 '10 #7
mseo
181 100+
thank you for your help msquared
now I understand this point
I appreciate you answer
thank you very much
Jan 17 '10 #8
MMcCarthy
14,534 Expert Mod 8TB
You are welcome.

To explain further you always have to do this when there is a many to many relationship. A supplier can have more than one product and a product can have more than one suppier. This is what's known as a many to many relationship.

The join table allows you to have a new table which has only a one to many relationship with the other two tables. You then add any fields to this table which are unique to the joint relationship like price.
Jan 17 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

43
by: grz02 | last post by:
Hi, Im an experienced database+software designer and developer, but, unfortunately, anything to do with web-programming and web-systems designs is still a pretty new area to me... (been working...
3
by: Rushikesh | last post by:
I am designing a WEB BASED Accounting Software with ASP and SQL Server. For this I need some help for the Database design. My design is as follows. I)User table: User_id, UserName..... Users...
5
by: Don Vaillancourt | last post by:
Hello all, Over the years as I design more database schemas the more I come up with patterns in database design. The more patterns I recognize the more I want to try to design some kind of...
1
by: Lane Beneke | last post by:
All, New to the list and a relative newbie to PostgreSQL. Please forgive stupid questions. Designing an application server for a work order processing (et al) database. I have a good handle...
1
by: E.U. | last post by:
Hi, I an using MS-Access in order to build a site. I have this item that can have upto 10 pictures (might have none) I want to design a dynamic table which has the ID of the item at the first...
2
by: Ray | last post by:
Stop me if you've heard this, but I am running Access 2002 and all of a sudden, if I design a particular form (it's been working fine for ages), Access crashes rather than open it in design view. ...
2
by: Matthew Hood | last post by:
My company has expressed a desire to convert an existing MS Access application to a full VB.NET application. My experience is with VB6 so I want to ask a few questions and get some input on the...
5
by: rdemyan via AccessMonster.com | last post by:
I have a need to add another field to all of my tables (over 150). Not data, but an actual field. Can I code this somehow. So the code presumabley would loop through all the tables, open each...
3
by: vicky | last post by:
Hi All, Can u please suggest me some books for relational database design or database modelling(Knowledgeable yet simple) i.e. from which we could learn database relationships(one to many,many to...
2
by: existential.philosophy | last post by:
This is a new problem for me: I have some queries that open very slowly in design view. My benchmark query takes about 20 minutes to open in design view. That same query takes about 20 minutes...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.