Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help me set up a database structure

Author  Topic 

CTucker1327
Starting Member

1 Post

Posted - 2013-10-20 : 02:54:35
Alright guys, so I know the basics, however, I'm venturing into my first application using SQL.

So far, this is what I have, but it's only theory.

Database Name: Login
Table Name: Accounts
Table Contents (ID, Username, password, Email)
==========================================================

Database Name: World
Table Name: Characters
Table Contents: (Owner, Name)


===========================================================

What I'm trying to do is write an application that logs in-to our master-server using the login details stored in the "Login Database" then bring up a list of "Characters" for that user, the way I imagined doing this was by storing the "Owner" variable in the Characters Table. I would then search for all of the matches for the Characters where the "Owner" matched the "Username" of the account in the Login table.

Is this the correct way to do this?

I'm trying to write my first SQL Server application, although it's not going to be perfect, I want it to be done correctly, or what's the point in using SQL when I could just use text-files for data-storage.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-10-20 : 03:11:00
Assuming your both databases (Login and World) are in same server you can use like

USE [Login]
GO
SELECT *
FROM dbo.Accounts a
INNER JOIN World.dbo.Characters c
ON c.Owner = a.Username


But IMO there's no need for separate dbs. You can keep the tables in the same database as there's no other settings that you need to apply separately for them
In that case the above query reduces to


SELECT *
FROM dbo.Accounts a
INNER JOIN dbo.Characters c
ON c.Owner = a.Username



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -