Was hoping someone could kick me in the right direction in regards stored procedures.
My issue is if I have a table that utilises foreign keys for other tables how do I update or use that data. Specifically I have a database for sports I want to enter a draw so teams matches in rounds at venues over a season. So i created a draw table
CREATE TABLE [dbo].[Draw](
[DrawId] [int] IDENTITY(1,1) NOT NULL,
[RoundNumberFk] [int] NULL,
[HomeTeam] [nchar](20) NULL,
[AwayTeam] [nchar](20) NULL,
[VenueFk] [int] NULL,
[Date] [datetime] NULL,
[TeamListFk] [int] NULL,
CONSTRAINT [PK_Draw] PRIMARY KEY CLUSTERED
As you can see there is a RoundNumberFK field. This comes from round.
CREATE TABLE [dbo].[Round](
[RoundID] [int] IDENTITY(1,1) NOT NULL,
[RoundNumber] [smallint] NULL,
CONSTRAINT [PK_Round] PRIMARY KEY CLUSTERED
Round goes to a join SeasonRound I have entered the round numbers and season details into that table already. No I want to enter in the teams home & away and the round and venue they are in.
In other words if I have inputted "season 2013" into the seasons table and added 1-26 in the rounds table, when i am updating the draw in the draw table, how to I use season 2013 with round 1 and add the teams to it so that they all match up?
So how do I link use the data from the round & season details to enter the match details?
Since I will consistently do this should it be a stored procedure?