Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 26th, 2006, 08:21 AM
Authorized User
 
Join Date: Nov 2005
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to x_ray
Default table format changed

hi all,
i am facing some problems with my database.i have a table with users info, in the same table there is a username and password,initially for each user there would be only one username and pass(account).But now i a have allow multiple accounts for the same person, which means i have to split the table into three:
 userstable:
userid fname lname (other info)
accounttable:
usename passwrd (other account info)
usersaccounttable:
userid username
 the problem is that the table is already populated with data, and the columns have all the same data type,is there a way to split the data into these three tables without loosing anything?
Thanks.


 
Old January 26th, 2006, 07:46 PM
SQLScott's Avatar
Wrox Author
 
Join Date: Dec 2004
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Why three tables? From what understand of your situation, you can do this with two tables.

Table1: User
userid(pk) fname lname (other info)

Table2: UserAccount
useraccountid(pk) userid (fk) usename passwrd (other account info)

Then, update the UserAccount:
INSERT INTO UserAccount (userid, username, passwrd) SELECT userid, username, passwrd FROM User

Scott

 
Old January 26th, 2006, 07:48 PM
SQLScott's Avatar
Wrox Author
 
Join Date: Dec 2004
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Let me add a little more.

By doing what you suggested below, the UserAccount table now has the ability to store multiple accounts for each User. This is accomplished via the Primary / Foreign key reference between the User and UserAccount tables.

I hope this helps...

Scott

 
Old February 4th, 2006, 07:06 AM
Authorized User
 
Join Date: Nov 2005
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to x_ray
Default

ok thanks for the tip but i gave only an example, here is the real problem:
table1
userid(pk) (otherinfo)
table2
useraccount(pk) userid(fk) username password status

the status is the same for all accounts of the user, and i made a mistake not to include it in the user table1, because now i have redundancy in table 2, however i solved the problem now, but i need a safe and simple way to avoid such situations in the future(other than carefully designing the DB hehehe)
thanks anyway, hope you got my point of view.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Number format in the table zrtv SQL Server 2005 6 March 7th, 2008 03:18 AM
export excel file ( format is changed ) urgent palanivel jayanthi ASP.NET 1.0 and 1.1 Professional 1 March 12th, 2007 05:32 PM
export excel file ( format is changed ) urgent palanivel jayanthi ASP.NET 1.0 and 1.1 Basics 1 March 12th, 2007 05:31 PM
web config file format changed sarah lee ASP.NET 1.0 and 1.1 Basics 0 September 29th, 2006 01:31 PM
Data has changed error with linked ODBC table Wim Leys Access 7 June 8th, 2004 06:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.