Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 12

Video Game Collection

A DATABASE BY ALEX SMITH


BIT 275 FALL 2016 (INSTRUCTOR: CRAIG DUCKETT)
Table Relationships

Games
Contains video games from my video game collection,
along with games on my wish list.
Platform
Contains all the platforms that are contained in the
Games table (e.g. Super Nintendo, PlayStation, etc.)
[one-to-many relationship]
Developer
A table containing video game developers seen in the
Games table. [one-to-many relationship]
Publisher
All the video game publishers shown in the Games
table. [one-to-many relationship]
Genres
All the video game genres seen in the Games table.
[one-to-many relationship]
Games Table CREATE TABLE [dbo].[Games]

Layout [GameID] INT NOT NULL PRIMARY KEY IDENTITY (1,1),

[GameName] NVARCHAR(100) NOT NULL,

[ReleaseDate] DATE NOT NULL,

[Platform] INT NULL,

[Developer] INT NULL,

[Publisher] INT NULL,

[GenreID] INT NULL,

[Owned] BIT NOT NULL,

CONSTRAINT [fk_games_togenres] FOREIGN KEY (GenreID)


REFERENCES [Genres]([GenreID]),

CONSTRAINT [fk_games_todeveloper] FOREIGN KEY (Developer)


REFERENCES [Developer]([ID]),

CONSTRAINT [fk_games_topublisher] FOREIGN KEY (Publisher)


REFERENCES [Publisher]([ID]),

CONSTRAINT [fk_games_toplatform] FOREIGN KEY (Platform)


REFERENCES [Platform]([ID])

GO
Joining Table CREATE TABLE [DBO].
[Developer]

Layout (
[ID] INT NOT NULL PRIMARY KEY
IDENTITY (1,1),
[DeveloperName] NVARCHAR(50)
NOT NULL
)

Repeat this for


developer,
publisher, genres
and platform
tables.
CREATE VIEW [dbo].[Select All Games]

Select All AS
SELECT dbo.Games.GameName,

Games in dbo.Games.ReleaseDate,
dbo.Platform.PlatformName, dbo.Genres.Genre,
dbo.Developer.DeveloperName,

Table dbo.Publisher.PublisherName,
dbo.Games.Owned
FROM dbo.Games INNER JOIN

What dbo.Developer ON
dbo.Games.Developer = dbo.Developer.Id INNER
JOIN
games dbo.Genres ON
dbo.Games.GenreID = dbo.Genres.GenreID INNER
are in my JOIN
dbo.Platform ON
collection dbo.Games.Platform = dbo.Platform.Id INNER
JOIN

? dbo.Publisher ON
dbo.Games.Publisher = dbo.Publisher.Id

GO
Select All
Games Results
Select All SELECT dbo.Games.GameName,
Sony dbo.Games.ReleaseDate,
dbo.Platform.PlatformName,

Games dbo.Developer.DeveloperName,
dbo.Publisher.PublisherName,
dbo.Games.Owned

What FROM dbo.Games INNER JOIN


dbo.Platform ON dbo.Games.Platform =
games do dbo.Platform.Id INNER JOIN
dbo.Developer ON dbo.Games.Developer =
I own that dbo.Developer.Id INNER JOIN
dbo.Publisher ON dbo.Games.Publisher =
are dbo.Publisher.Id
WHERE
published (dbo.Publisher.PublisherName = N'Sony')

by Sony?
Select All Sony
Games Results
Stored QUICKLY INSERT DATA INTO
VARIOUS TABLES WITH
Procedures MINIMUM KEYSTROKES.
Insert into Joining Tables

AddDeveloper (nvarchar(50)) inserts a developer into the


Developer table.
AddPublisher (nvarchar(50)) inserts a publisher into the Publisher
table.
AddGenre (nvarchar(50)) inserts a genre into the Genre table.
AddPlatform (nvarchar(50)) inserts a new video game console into
the Platform table.
AddNewGame
(nvarchar(100),dat
e,int,int,int,int,bit)

Inserts (@GameName,
@ReleaseDate, @Platform,
@Developer, @Publisher, @Genre,
@Owned) into the Games table.
Games data

You might also like