473,386 Members | 1,738 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,386 software developers and data experts.

Database design question?

hi
I have two table named Purchase and Sale..all of fields of
both tables are the same...I make them design in one table
with an additional boolean field to determine which is Sale and Purchase...
it is good to design them in seperate tables without additional field??
or design both in one table...

Nov 16 '05 #1
7 1862
Hi,
Personally, I prefer to have all data in the same table for avoiding
the redundancy but it can be (little) more difficult to make a good
sql if you need to compare Sale and Purchase ….ex(select * from
(select… from Sales=1) as Sale, (select …. from Purchase where
Purchase = 1) as Purchase from Purchase.id =Sale.id)
And with good index it will be very performant.

Otherwise, if you use sql server 2000, you have the index view it can
be very useful in your case.

Bye

On Tue, 21 Dec 2004 06:46:39 +0330, "perspolis" <re*****@hotmail.com>
wrote:
hi
I have two table named Purchase and Sale..all of fields of
both tables are the same...I make them design in one table
with an additional boolean field to determine which is ...
it is good to design them in seperate tables without additional field??
or design both in one table...


Nov 16 '05 #2
Hello there, personally I would split them into two tables and link them
using their primary key - this allows you the flexibility to modify the
structure of the tables independantly of each other, a purchase or sale
could have an attribute which does not apply to both entities

regards

Pete Kane
"perspolis" <re*****@hotmail.com> wrote in message
news:OE**************@TK2MSFTNGP11.phx.gbl...
hi
I have two table named Purchase and Sale..all of fields of
both tables are the same...I make them design in one table
with an additional boolean field to determine which is Sale and
Purchase...
it is good to design them in seperate tables without additional field??
or design both in one table...

Nov 16 '05 #3
Hi,

IT depends of several things among others:
1- How big the table can get
2- Concurrency issues
3- PK generation, maybe you want a different sequence for sales & purchases
If you decide to have both together you can create two views one for sales
and another for purchases and make all the operations agains them. this will
abstract the real table composition.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"perspolis" <re*****@hotmail.com> wrote in message
news:OE**************@TK2MSFTNGP11.phx.gbl...
hi
I have two table named Purchase and Sale..all of fields of
both tables are the same...I make them design in one table
with an additional boolean field to determine which is Sale and
Purchase...
it is good to design them in seperate tables without additional field??
or design both in one table...

Nov 16 '05 #4
thx to all who reply me..
if tables for Sale and Purchase are big, I think it's better to have them
seperatedly...isn't it??

"perspolis" <re*****@hotmail.com> wrote in message
news:OE**************@TK2MSFTNGP11.phx.gbl...
hi
I have two table named Purchase and Sale..all of fields of
both tables are the same...I make them design in one table
with an additional boolean field to determine which is Sale and Purchase... it is good to design them in seperate tables without additional field??
or design both in one table...

Nov 16 '05 #5
I would always go the two table route, the difference in storage space is
negligible and the redundancy hardly woth worrying about, what database are
you going to use ?

Pete Kane
"perspolis" <re*****@hotmail.com> wrote in message
news:uQ**************@TK2MSFTNGP11.phx.gbl...
thx to all who reply me..
if tables for Sale and Purchase are big, I think it's better to have them
seperatedly...isn't it??

"perspolis" <re*****@hotmail.com> wrote in message
news:OE**************@TK2MSFTNGP11.phx.gbl...
hi
I have two table named Purchase and Sale..all of fields of
both tables are the same...I make them design in one table
with an additional boolean field to determine which is Sale and

Purchase...
it is good to design them in seperate tables without additional field??
or design both in one table...


Nov 16 '05 #6
Hello perspolis,

No. Database size is not normally a factor in design. With tables like
Purchase and Sale, I strongly doubt that you will ever have the size of
table that would drive you away to denormalize your design in this way. In
a data warehouse I worked on, we had a single table that contained 20
Billion rows. SQL Server 2000 didn't even flinch. (some operations took a
while :-)

Do not make your decision on the basis of expected size. If the business
has different Meanings for these two tables, and considers them to be
entirely different and unrelated things, then you are better off in
different tables because the business may decide to add fields to one that
are not in the other, or create a complex indexing scheme for only one of
the two tables.

On the other hand, if the business expects to move an item through "stages"
where it is a purchase until an event occurs, and then it is a sale, then
use one table. Otherwise, you will have a much more difficult time
answering basic questions like "has customer X been involved in the purchase
or sale of item Y" and "provide the total of all purchases and sales for
category Z"

I do not know your system. The word "purchase" says "accounts payable"
while the word "sale" says "accounts receivable" to me. If that's what
these mean to you too (or the inventory equivalents), then you definitely
want two different tables. The reason being this: when you purchase
something, you purchase it from someone. When you sell something, you sell
it to someone. These "someone" entities need to have some form of
uniqueness to them. Otherwise, your reporting becomes very difficult to do.

--- Nick
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"perspolis" <re*****@hotmail.com> wrote in message
news:uQ**************@TK2MSFTNGP11.phx.gbl...
thx to all who reply me..
if tables for Sale and Purchase are big, I think it's better to have them
seperatedly...isn't it??

"perspolis" <re*****@hotmail.com> wrote in message
news:OE**************@TK2MSFTNGP11.phx.gbl...
hi
I have two table named Purchase and Sale..all of fields of
both tables are the same...I make them design in one table
with an additional boolean field to determine which is Sale and

Purchase...
it is good to design them in seperate tables without additional field??
or design both in one table...


Nov 16 '05 #7
I'm using Sql Server 2000 ..
I think for huge information it's better to have them seperatedly..because
there is no nedd to get addtional field to know that's Sale or Purchase..
but in my situation fields of Sale and Purchase are the same..

"Pete Kane" <pk****@ntlworld.com> wrote in message
news:7S**************@newsfe4-gui.ntli.net...
I would always go the two table route, the difference in storage space is
negligible and the redundancy hardly woth worrying about, what database are you going to use ?

Pete Kane
"perspolis" <re*****@hotmail.com> wrote in message
news:uQ**************@TK2MSFTNGP11.phx.gbl...
thx to all who reply me..
if tables for Sale and Purchase are big, I think it's better to have them seperatedly...isn't it??

"perspolis" <re*****@hotmail.com> wrote in message
news:OE**************@TK2MSFTNGP11.phx.gbl...
hi
I have two table named Purchase and Sale..all of fields of
both tables are the same...I make them design in one table
with an additional boolean field to determine which is Sale and

Purchase...
it is good to design them in seperate tables without additional field??
or design both in one table...



Nov 16 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Lefevre, Steven | last post by:
Hey folks - Thanks to everyone who gave input to my concerns. Of course, we don't intend to have the mysql port open to the world. We will have Apache/PHP connect on a unix socket, or to another...
2
by: Josh McFarlane | last post by:
If this is not the right place to post this, I apologize. I've taken over work for a few utility programs for a collection of database / raw files. All the programs but one read from the files,...
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...
29
by: MP | last post by:
Greets, context: vb6/ado/.mdb/jet 4.0 (no access)/sql beginning learner, first database, planning stages (I think the underlying question here is whether to normalize or not to normalize this...
12
by: nyathancha | last post by:
Hi, I have a question regarding best practices in database design. In a relational database, is it wise/necessary to sometimes create tables that are not related to other tables through a...
1
by: arrival123 | last post by:
Hello, I'm currently trying to decide on a database design for tags in my web 2.0 application. The problem I'm facing is that I have 3 separate tables i.e. cars, planes, and schools. All three...
10
by: ARC | last post by:
Hello all, General question for back-end database that has numerous date fields where the database will be used in regions that put the month first, and regions that do not. Should I save a...
4
by: dgleeson3 | last post by:
Hello all I am creating a VB.Net distributed SQL server 2005 application. Each computer in the system has a database with a table of users and their telephone numbers. Each computer has a...
0
by: David | last post by:
Hi list. I have a few database-related questions. These aren't Python-specific questions, but some of my apps which use (or will use) these tables are in Python :-) Let me know if I should ask...
10
by: Les Desser | last post by:
In article <fcebdacd-2bd8-4d07-93a8-8b69d3452f3e@s50g2000hsb.googlegroups.com>, The Frog <Mr.Frog.to.you@googlemail.comMon, 14 Apr 2008 00:45:10 writes Not sure if I quite follow that. 1....
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: 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:
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.