SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help me set up a database structure
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

CTucker1327
Starting Member

USA
1 Posts

Posted - 10/20/2013 :  02:54:35  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 10/20/2013 :  03:11:00  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000