473,759 Members | 7,748 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding a column to an existing table with data

Raj
Hi,
I am trying to add some more information to the table which already
has a lot a data (like 2-3000 records). The new information may be
adding 2-3 new columns worth. Now my questions are:
(1)Is it a good idea to add new columns to the existing table? then it
will create these new columns for all old records, will it not result
in wasting a lot of space??
(2)Is it a good idea to create a new table with the new information
and have as a forign key the index value from the first table?
There may be answers to these questions already in some threads but
since I dont have much time I thought I will post it again, if these
are already answered by someone could someone point me there? any help
would be appreciated, thanks,
raj.
Nov 12 '05 #1
3 4908
It is rarely a good idea to add columns to a table -
especially not if this is something that happens repeatedly.

Consider normalizing your table design -
most likely moving some of your existing data into a new table.

For example, suppose you had a table of children and schools -
PK
Child's Name
Child's School
Then children begin changing schools, and you want a historical record.
You might think of a structure like this:
PK
Child's Name
Child's School 1
Child's Dates at School1
Child's School 2
Child's Dates at School2
Of course this will be problematic, because you'll have to keep adding
fields...

Instead, you could have 2 tables
PK
Child's Name
and
Foreign Key - matches PK of first table to identify child
School Name
School Start
School End

This will accommodate as many schools as needed.

HTH
- Turtle

"Raj" <en****@yahoo.c om> wrote in message
news:d3******** *************** ***@posting.goo gle.com...
Hi,
I am trying to add some more information to the table which already
has a lot a data (like 2-3000 records). The new information may be
adding 2-3 new columns worth. Now my questions are:
(1)Is it a good idea to add new columns to the existing table? then it
will create these new columns for all old records, will it not result
in wasting a lot of space??
(2)Is it a good idea to create a new table with the new information
and have as a forign key the index value from the first table?
There may be answers to these questions already in some threads but
since I dont have much time I thought I will post it again, if these
are already answered by someone could someone point me there? any help
would be appreciated, thanks,
raj.

Nov 12 '05 #2
Raj
Thanks, in my case I cant do anything with the existing table, apart
from adding a column or two at the most since there are a lot of
people using the database in its original format, even that will be
tough as we may have to update all the users databases once we rollout
the new changes, so I guess the best idea in this case is to add a new
table with all the new data and a foreign-key to link into the main
table...am I right?? Thanks again,
Raj.

"MacDermott " <ma********@nos pam.com> wrote in message news:<VR******* *********@newsr ead1.news.atl.e arthlink.net>.. .
It is rarely a good idea to add columns to a table -
especially not if this is something that happens repeatedly.

Consider normalizing your table design -
most likely moving some of your existing data into a new table.

For example, suppose you had a table of children and schools -
PK
Child's Name
Child's School
Then children begin changing schools, and you want a historical record.
You might think of a structure like this:
PK
Child's Name
Child's School 1
Child's Dates at School1
Child's School 2
Child's Dates at School2
Of course this will be problematic, because you'll have to keep adding
fields...

Instead, you could have 2 tables
PK
Child's Name
and
Foreign Key - matches PK of first table to identify child
School Name
School Start
School End

This will accommodate as many schools as needed.

HTH
- Turtle

Nov 12 '05 #3
The only case in which I would recommend your approach is if you know this
application will be replaced soon, and just need something to bridge the
gap.
One way or another, you're going to have to inconvenience your users to make
this change.
Why not just inconvenience them once, and give them a more flexible
structure, so further changes won't be such an inconvenience?

My general rule is that data structure changes should be made as early as
possible.
Trying to work around poorly designed tables has not been worth the
"savings" in my experience.

HTH
- Turtle
"Raj" <en****@yahoo.c om> wrote in message
news:d3******** *************** ***@posting.goo gle.com...
Thanks, in my case I cant do anything with the existing table, apart
from adding a column or two at the most since there are a lot of
people using the database in its original format, even that will be
tough as we may have to update all the users databases once we rollout
the new changes, so I guess the best idea in this case is to add a new
table with all the new data and a foreign-key to link into the main
table...am I right?? Thanks again,
Raj.

"MacDermott " <ma********@nos pam.com> wrote in message

news:<VR******* *********@newsr ead1.news.atl.e arthlink.net>.. .
It is rarely a good idea to add columns to a table -
especially not if this is something that happens repeatedly.

Consider normalizing your table design -
most likely moving some of your existing data into a new table.

For example, suppose you had a table of children and schools -
PK
Child's Name
Child's School
Then children begin changing schools, and you want a historical record.
You might think of a structure like this:
PK
Child's Name
Child's School 1
Child's Dates at School1
Child's School 2
Child's Dates at School2
Of course this will be problematic, because you'll have to keep adding
fields...

Instead, you could have 2 tables
PK
Child's Name
and
Foreign Key - matches PK of first table to identify child
School Name
School Start
School End

This will accommodate as many schools as needed.

HTH
- Turtle

Nov 12 '05 #4

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

Similar topics

5
2792
by: Paul | last post by:
Hi I have a table that currently has 466 columns and about 700,000 records. Adding a new DEFAULT column to this table takes a long time. It it a lot faster to recreate the table with the new columns and then copy all of the data across. As far as I am aware when you add a DEFAULT column the following happens:
2
2919
by: Gail Zacharias | last post by:
I am investigating the possibility of using pgsql as the database in an application. I have some unusual requirements that I'd like to ask you all about. I apologize in advance if my terminology is a little "off", I'm not familiar with pgsql (yet). My first requirement is that I need to be able to add new columns to any database table on the fly. By this I mean that I need this to happen interactively -- a user will drag some UI widget...
11
14412
by: Bobbak | last post by:
Hello All, I have these tables (lets call it ‘EmpCalls', ‘EmpOrders', and ‘Stats') that each contain the list of EmployeeIDs, I want to be able to create a Module in which I could call in my VB form (by clicking and command button)that will add a column (field) to each table and label it with the current date that is specified in my form. Does anyone know how I can go about doing this? Any suggestion will be greatly appreciated.
3
53772
by: GL | last post by:
Hi, Is there a way to add a field to an existing table using a query of some sort (without needing to manually add a field to the table). I know how to do it with a make table query, but I have a specific need to only add a new field to a table if possible. Here's a simplified example of what I'm trying to do: I get a file with the following two fields: First Name
12
3577
by: Art | last post by:
Hi everyone I was hoping someone might be able to help me with this. I'm just starting to try to work with MS Access tables through VB.net. In Access I can take an existing table and add a new field with the type AutoNumber. I can then set this up as a key. Then if I go into the table I will see sequential numbers have been inserted into that field for me. Can I do this through VB.net I'd appreciate any help or alternative suggestions...
6
4430
by: Rudy | last post by:
Hi all, I know this is easy, just can't seem to get it. I have a windows form, and a text box, with a value already in it. I need to add that value to a table. It's just one value, so the entire row doesn't get filled. I have a connection and all that stuff. Private Sub btnPlaceBet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlaceBet.Click ' Dim Myds As Footbet.DStable '...
7
1788
by: Miro | last post by:
Im a VB Newbie so I hope I'm going about this in the right direction. I have a simple DB that has 1 Table called DBVersion and in that table the column is CurVersion ( String ) Im trying to connect to the db, and then add a record to the DBVersion table. Except I cant. I have 1 line that crashes and if i rem it out it works but nothing gets added.
13
22068
by: annecarterfredi | last post by:
I'd like to add a new column to an existing table at a specific column location... Existing table definition: MyTable(Col1, Col2, Col3) I want to add a new column in MyTable and the new column's position is in between Col2 and Col3: MyTable(Col1, Col2, New_Column, Col3)
9
10115
by: mamoon | last post by:
hi all, Question: i have a table in a database of 6 columns and 630 rows.i want to add one new column to this table and also update this column starting from row 1 to row 630. System information: 1.Linux ac8d7f39.ipt.aol.com 2.6.9-5.ELsmp #1 SMP Wed Jan 5 19:30:39 EST 2005 i686 i686 i386 GNU/Linux 2. PostgreSQL 7.4.6 My trial: 1. i added one column with ALTER TABLE command
0
10107
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9945
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9900
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7324
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5214
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3863
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3442
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.