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
 Advice on creating a table, please

Author  Topic 

Eagle_f90
Constraint Violating Yak Guru

424 Posts

Posted - 2012-03-21 : 07:54:29
I am making a game information web site and need a bit of help on how to design a table. I currently have a master table called "CharacterInfoGeneral"

CREATE TABLE dbo.CharacterInfoGeneral
(
CharacterID int IDENTITY(0,1) NOT NULL,
SectionID smallint NOT NULL,
CharacterName varchar(50) NOT NULL,
Gender char(1) NOT NULL DEFAULT 'U',
RaceID int NOT NULL,
AboutCharacter varchar(MAX) NOT NULL DEFAULT 'Sorry there is no information about this Character yet.',
CONSTRAINT PK_CharacterInfoGeneral_CharacterID PRIMARY KEY CLUSTERED (CharacterID ASC),
CONSTRAINT FK_CharacterInfoGeneral_SectionID FOREIGN KEY (SectionID) REFERENCES dbo.SectionInfo (SectionID),
CONSTRAINT FK_CharacterInfoGeneral_RaceID FOREIGN KEY (RaceID) REFERENCES dbo.RaceInfo (RaceID)
)


I now want to create a table that will house unique information for each character from specific games. There are over 150 games so far and each one has some sort of unique info. I was able to come up with two approaches for this. The first was to create a new table for each game to house the unique information and the second was to have a single table with an attribute and value colums. I am leaning tword the second way as this would mean I do not have to create new tables when ever a new game comes out. Am i on the right path with going with the attribute/value table?

--
If I get used to envying others...
Those things about my self I pride will slowly fade away.
-Stellvia

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-21 : 10:04:48
yep...you're
just add gameid also in second table as a fk to indicate which games info it represents

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-03-21 : 11:34:12
Unless the character can be associated with more than one game. :)
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-21 : 11:46:44
Make the PK CharID and GameID

And have 1 table for chars and one for games and a CharGames table to identify what chars belong in what games....

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

Eagle_f90
Constraint Violating Yak Guru

424 Posts

Posted - 2012-03-21 : 17:39:39
Thanks for the replay. I already have a table for GameID which CharacterInfoGeneral references with a FK.

--
If I get used to envying others...
Those things about my self I pride will slowly fade away.
-Stellvia
Go to Top of Page
   

- Advertisement -