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

Null & one more table

Hello,

I want to store two information (so 2 columns) for 2/3rd of the rows
that will be in a table
and only one information (1 column is suffecient) for 1/3rd of the
rows of the table.

ex:
jb_id, previous_jb_id -------- for 2/3rd of the rows
jb_id -------- for 1/3rd of the rows

What is better

#1) add both the column (jb_id, previous_jb_id ) in the table itself.
disadvantage:
By this for 1/3rd of the rows, previous_jb_id will be NULL

#2) create different table for storing previous_jb_id for required
rows only.
disadvantage:
1) more table---> more Joins & more table to update
2) more Joins --->slow
& more Joins ---> bit difficult to write "select" queries.

Thanks in advance.
waiting for reply.
Jul 20 '05 #1
3 1554
Hi

I am not sure why you think having a NULL column is a problem, they take up
little space?

John

"A.V.C." <yh*****************@hotmail.com> wrote in message
news:d2*************************@posting.google.co m...
Hello,

I want to store two information (so 2 columns) for 2/3rd of the rows
that will be in a table
and only one information (1 column is suffecient) for 1/3rd of the
rows of the table.

ex:
jb_id, previous_jb_id -------- for 2/3rd of the rows
jb_id -------- for 1/3rd of the rows

What is better

#1) add both the column (jb_id, previous_jb_id ) in the table itself.
disadvantage:
By this for 1/3rd of the rows, previous_jb_id will be NULL

#2) create different table for storing previous_jb_id for required
rows only.
disadvantage:
1) more table---> more Joins & more table to update
2) more Joins --->slow
& more Joins ---> bit difficult to write "select" queries.

Thanks in advance.
waiting for reply.

Jul 20 '05 #2
A.V.C. (yh*****************@hotmail.com) writes:
I want to store two information (so 2 columns) for 2/3rd of the rows
that will be in a table
and only one information (1 column is suffecient) for 1/3rd of the
rows of the table.

ex:
jb_id, previous_jb_id -------- for 2/3rd of the rows
jb_id -------- for 1/3rd of the rows

What is better

#1) add both the column (jb_id, previous_jb_id ) in the table itself.
disadvantage:
By this for 1/3rd of the rows, previous_jb_id will be NULL

#2) create different table for storing previous_jb_id for required
rows only.
disadvantage:
1) more table---> more Joins & more table to update
2) more Joins --->slow
& more Joins ---> bit difficult to write "select" queries.


For the case given, I vote for #1.

That does mean to say that #1 is always the best. Say that you had 20
columns in the table, and of these six would only apply to a subset of
the rows. (And all six apply to the same subset.) In this case a subtable
is more palatable, as it makes the main table easier to grasp.

Another situation is when you have a large table, and you have some columns
that apply only to a very small subset of rows. In this case you can save
space (and thus time) by moving these columns to a side table. Note that
if the columns are varchar columns that else are NULL, there is not much
to win. But for fixed-width columns NULL takes up the same space as a value.
Also, the overall size for the table matters. Moving out 24 bytes of 520 per
row may not be worth it, but 24 of 56 bytes can give a huge effect.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3
Thanks Erland Sommarskog & John Bell
I will use #1 approach..
Erland Sommarskog <es****@sommarskog.se> wrote in message news:<Xn**********************@127.0.0.1>...
A.V.C. (yh*****************@hotmail.com) writes:
I want to store two information (so 2 columns) for 2/3rd of the rows
that will be in a table
and only one information (1 column is suffecient) for 1/3rd of the
rows of the table.

ex:
jb_id, previous_jb_id -------- for 2/3rd of the rows
jb_id -------- for 1/3rd of the rows

What is better

#1) add both the column (jb_id, previous_jb_id ) in the table itself.
disadvantage:
By this for 1/3rd of the rows, previous_jb_id will be NULL

#2) create different table for storing previous_jb_id for required
rows only.
disadvantage:
1) more table---> more Joins & more table to update
2) more Joins --->slow
& more Joins ---> bit difficult to write "select" queries.


For the case given, I vote for #1.

That does mean to say that #1 is always the best. Say that you had 20
columns in the table, and of these six would only apply to a subset of
the rows. (And all six apply to the same subset.) In this case a subtable
is more palatable, as it makes the main table easier to grasp.

Another situation is when you have a large table, and you have some columns
that apply only to a very small subset of rows. In this case you can save
space (and thus time) by moving these columns to a side table. Note that
if the columns are varchar columns that else are NULL, there is not much
to win. But for fixed-width columns NULL takes up the same space as a value.
Also, the overall size for the table matters. Moving out 24 bytes of 520 per
row may not be worth it, but 24 of 56 bytes can give a huge effect.

Jul 20 '05 #4

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

Similar topics

16
by: cwizard | last post by:
I'm calling on a function from within this form, and there are values set but every time it gets called I get slammed with a run time error... document.frmKitAmount.txtTotalKitValue is null or not...
7
by: BlueDragon | last post by:
I don't know enough math to demonstrate that any numerical operation with a null should yield a null; although I would guess that it's true. I just don't buy it, however, when dealing with strings...
6
by: Tina | last post by:
in the itemDatabound event of a datagrid, both null fields and blank string come through as &nbsp; in the e.items.cells field. Is there anyway to tell them apart? Thanks, T
3
by: Ganesh Palaniappan | last post by:
We're getting following exception for the below piece of code. We're wondering how it is possible since we're having a null check for objGraphics and strokePen... Exception:...
3
by: Bob Sanderson | last post by:
I have a PHP web page which uses a HTML form. I would like to enter dates into the date fields using a JavaScript calendar, similar to the way phpMyAdmin does. Can anyone recommend a JavaScript...
2
by: nkumarin001 | last post by:
Hi, I have some doubts regarding NULL values. Can any one help me in clearing my doubts. I have created a table:- create table suppliers ( supplier_id number, supplier_name...
1
by: billa856 | last post by:
Hi, I am trying to insert Null value in column(ShipDate) in my table.That column(ShipDate)'s type id date/time and format is short date. I am using "" to insert Null in that column(ShipDate)...
4
by: ilikebirds | last post by:
I am trying to update a table that is Inner Joined or related to 2 other tables with similiar data. For Instance: Table 1 ----------- A - B -------- y - x z - null Table 2
2
by: MATTXtwo | last post by:
I have this store procedure to select data from table with join like this...SELECT tblPeribadi.Personel_No, tblPeribadi.Nama,tblCompany.Keterangan as Company_Code, tblPeribadi.Jawatan,...
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: 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.