473,398 Members | 2,113 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,398 software developers and data experts.

one to one releation

dear all,
a simple quetion for database experts.
can three datatables be updated at the same time (from one page)with
one table having one primary key
and other two tables are having that primary key as foreign key in
there tables.

tables with foreign keys are linked to parent table(having primary key)
with one-to-one releation.

this one-to-one releation was made due to large number of columns for
the same table, so it was divided.

what method will be sutible to update the record from same page ?

thanks in advance.

Jul 6 '06 #1
3 1102
A stored procedure that executes the update of both tables within a
transaction.
<na********@yahoo.comwrote in message
news:11********************@j8g2000cwa.googlegroup s.com...
dear all,
a simple quetion for database experts.
can three datatables be updated at the same time (from one page)with
one table having one primary key
and other two tables are having that primary key as foreign key in
there tables.

tables with foreign keys are linked to parent table(having primary key)
with one-to-one releation.

this one-to-one releation was made due to large number of columns for
the same table, so it was divided.

what method will be sutible to update the record from same page ?

thanks in advance.

Jul 6 '06 #2

Andrew Robinson wrote:
A stored procedure that executes the update of both tables within a
transaction.
<na********@yahoo.comwrote in message
news:11********************@j8g2000cwa.googlegroup s.com...
dear all,
a simple quetion for database experts.
can three datatables be updated at the same time (from one page)with
one table having one primary key
and other two tables are having that primary key as foreign key in
there tables.

tables with foreign keys are linked to parent table(having primary key)
with one-to-one releation.

this one-to-one releation was made due to large number of columns for
the same table, so it was divided.

what method will be sutible to update the record from same page ?

thanks in advance.
thankyou dear for reply
will you please give any link to the relavent article(one to one
updations).

Jul 7 '06 #3
If two (or more) tables have a one:one relation then they are really just
one big table. You could just combine them. that said, a transaction is
pretty easy. You could create a stored procedure that says something like

PROCEDURE [dbo].[mySproc] -- declare your stored procedure

@ModifiedBy varchar(100), -- pass in some parameters

@LongDescription varchar(2000),

@val1 int,

@Notes varchar(3000)

@val2 int

AS

BEGIN

Begin Transaction -- start the transaction

declare @foo as int -- local variables

declare @theTime as datetime

set @theTime = GetDate()

Insert into Table1 (col1, col2)

values (@theTime, @val1)

select @theIdentity= @@identity -- get the identity

if @@error <0 goto errorHandler -- if it fails, roll back

insert into table2( theIdentity, val1, theTime , ModifiedBy,
LongDescription, val2, Notes)

values (foo, 1, @theTime, @ModifiedBy, @LongDescription, @val2, @Notes)

if @@error <0 goto errorHandler -- if the second insert fails, roll it
all back

commit transaction -- otherwise, both scuceeded, so commit the transaction

goto done

errorHandler:
rollback transaction

done:
-- okay, so exit

Hope that helps.
--

Jesse Liberty
Author, Programmer
Microsoft MVP
<na********@yahoo.comwrote in message
news:11**********************@s16g2000cws.googlegr oups.com...
>
Andrew Robinson wrote:
>A stored procedure that executes the update of both tables within a
transaction.
<na********@yahoo.comwrote in message
news:11********************@j8g2000cwa.googlegrou ps.com...
dear all,
a simple quetion for database experts.
can three datatables be updated at the same time (from one page)with
one table having one primary key
and other two tables are having that primary key as foreign key in
there tables.

tables with foreign keys are linked to parent table(having primary key)
with one-to-one releation.

this one-to-one releation was made due to large number of columns for
the same table, so it was divided.

what method will be sutible to update the record from same page ?

thanks in advance.

thankyou dear for reply
will you please give any link to the relavent article(one to one
updations).

Jul 7 '06 #4

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

Similar topics

3
by: dusty | last post by:
Hi, I'll try to simplify the problem: I created a table "TestTable" in a database on the SQL server. The first column, 'id', is the primary key with a auto-increment identity. I want to work...
0
by: Oney | last post by:
For globalization I want to hold data in Sql server and as hashtable in the cache.So I created a table (LanguageId,Key,Value) in sql server. I don't want to pull strings all the time the page is...
9
by: Mr Newbie | last post by:
HI People, Thanks to all who helped me earlier on the subject of @@IDentity. However, I seem to have hit another snagette! My DataSet contains two tables from the SQL Server. lets say Master...
7
by: Marchetto | last post by:
Hi all. I thought that it was a FAQ.... but I can't find answer so i post in this NG. I have a dataset with two datatables (dt1 and dt2) in my application. I'd like to know if there is a...
7
by: Doug Parker | last post by:
I'm trying to use the repeater control to create a column-like row of data, I've searched the net and it doesn't appear to be that easy. Use this page for reference: ...
1
by: BD | last post by:
I am running VS 2005 writing in C# accessing remote SQL Server 2005 database. I want to develope a custom listing of the relationship between Customers and Locations (one to many) in a combo box. ...
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: 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: 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:
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,...
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...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.