diff --git a/.gitignore b/.gitignore index b48d181..ae8c535 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,490 @@ /TrackerLibrary/obj /TrackerUI/obj + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from `dotnet new gitignore` + +# dotenv files +.env + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml +.idea/ + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/main/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/main/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Vim temporary swap files +*.swp + + diff --git a/TournamentTracker.sln b/TournamentTracker.sln index aae8b53..1a990dc 100644 --- a/TournamentTracker.sln +++ b/TournamentTracker.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrackerLibrary", "TrackerLi EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrackerUI", "TrackerUI\TrackerUI.csproj", "{8EB74BF4-C68D-42F8-A891-51A2DFCB9BB1}" EndProject +Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "TournamentsDB", "TournamentsDB\TournamentsDB.sqlproj", "{597714D5-8069-4CDA-9919-DB5775FB027B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,12 @@ Global {8EB74BF4-C68D-42F8-A891-51A2DFCB9BB1}.Debug|Any CPU.Build.0 = Debug|Any CPU {8EB74BF4-C68D-42F8-A891-51A2DFCB9BB1}.Release|Any CPU.ActiveCfg = Release|Any CPU {8EB74BF4-C68D-42F8-A891-51A2DFCB9BB1}.Release|Any CPU.Build.0 = Release|Any CPU + {597714D5-8069-4CDA-9919-DB5775FB027B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {597714D5-8069-4CDA-9919-DB5775FB027B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {597714D5-8069-4CDA-9919-DB5775FB027B}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {597714D5-8069-4CDA-9919-DB5775FB027B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {597714D5-8069-4CDA-9919-DB5775FB027B}.Release|Any CPU.Build.0 = Release|Any CPU + {597714D5-8069-4CDA-9919-DB5775FB027B}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TournamentsDB/TournamentsDB.sqlproj b/TournamentsDB/TournamentsDB.sqlproj new file mode 100644 index 0000000..f40b88c --- /dev/null +++ b/TournamentsDB/TournamentsDB.sqlproj @@ -0,0 +1,98 @@ + + + + Debug + AnyCPU + TournamentsDB + 2.0 + 4.1 + {597714d5-8069-4cda-9919-db5775fb027b} + Microsoft.Data.Tools.Schema.Sql.Sql160DatabaseSchemaProvider + Database + + + TournamentsDB + TournamentsDB + 1033, CI + BySchemaAndSchemaType + True + v4.7.2 + CS + Properties + False + True + True + + + bin\Release\ + $(MSBuildProjectName).sql + False + pdbonly + true + false + true + prompt + 4 + + + bin\Debug\ + $(MSBuildProjectName).sql + false + true + full + false + true + true + prompt + 4 + + + 11.0 + + True + 11.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spMatchupEntries_GetByMatchup.sql b/TournamentsDB/dbo/Stored Procedures/spMatchupEntries_GetByMatchup.sql new file mode 100644 index 0000000..060e932 --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spMatchupEntries_GetByMatchup.sql @@ -0,0 +1,14 @@ +CREATE PROCEDURE [spMatchupEntries_GetByMatchup] + @MatchupId int + +AS +BEGIN + + SET NOCOUNT ON; + + select me.* + from MatchupEntries me + inner join Matchups m on me.MatchupId = m.id + where m.id = @MatchupId; + +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spMatchupEntries_Insert.sql b/TournamentsDB/dbo/Stored Procedures/spMatchupEntries_Insert.sql new file mode 100644 index 0000000..2cfbc28 --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spMatchupEntries_Insert.sql @@ -0,0 +1,19 @@ +-- ============================================= +-- Author: Alejandro +-- Create date: 2/4/2024 +-- Description: Inserts a new matchup entry. +-- ============================================= +CREATE PROCEDURE dbo.spMatchupEntries_Insert + @MatchupId int, + @ParentMatchupId int, + @TeamCompetingId int, + @id int = 0 output +AS +BEGIN + SET NOCOUNT ON; + + insert into MatchupEntries(MatchupId,ParentMatchupId,TeamCompetingId) + values (@MatchupId,@ParentMatchupId,@TeamCompetingId); + + select @id = SCOPE_IDENTITY(); +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spMatchupEntries_Update.sql b/TournamentsDB/dbo/Stored Procedures/spMatchupEntries_Update.sql new file mode 100644 index 0000000..e3727c7 --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spMatchupEntries_Update.sql @@ -0,0 +1,18 @@ +-- ============================================= +-- Author: Alejandro +-- Create date: 4/2/2024 +-- Description: Updates the team competing id or the score of a matchup entry. +-- ============================================= +CREATE PROCEDURE dbo.spMatchupEntries_Update + @id int, + @TeamCompetingId int = null, + @Score float = null +AS +BEGIN + SET NOCOUNT ON; + + update dbo.MatchupEntries + set TeamCompetingId = @TeamCompetingId, Score = @Score + where id = @Id; + +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spMatchups_GetByTournament.sql b/TournamentsDB/dbo/Stored Procedures/spMatchups_GetByTournament.sql new file mode 100644 index 0000000..9d9dbbe --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spMatchups_GetByTournament.sql @@ -0,0 +1,14 @@ +CREATE PROCEDURE [spMatchups_GetByTournament] + @TournamentId int + +AS +BEGIN + + SET NOCOUNT ON; + + select m.* + from Matchups as m + where m.TournamentId = @TournamentId + order by MatchupRound; + +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spMatchups_Insert.sql b/TournamentsDB/dbo/Stored Procedures/spMatchups_Insert.sql new file mode 100644 index 0000000..68ae610 --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spMatchups_Insert.sql @@ -0,0 +1,18 @@ +-- ============================================= +-- Author: Alejandro +-- Create date: 2/4/2024 +-- Description: Inserts a new matchup. +-- ============================================= +CREATE PROCEDURE dbo.spMatchups_Insert + @TournamentId int, + @MatchupRound int, + @id int = 0 output +AS +BEGIN + SET NOCOUNT ON; + + insert into Matchups(TournamentId,MatchupRound) + values (@TournamentId,@MatchupRound); + + select @id = SCOPE_IDENTITY(); +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spMatchups_Update.sql b/TournamentsDB/dbo/Stored Procedures/spMatchups_Update.sql new file mode 100644 index 0000000..714b893 --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spMatchups_Update.sql @@ -0,0 +1,17 @@ +-- ============================================= +-- Author: Alejandro +-- Create date: 4/2/2024 +-- Description: Updates the winner id of a matchup. +-- ============================================= +CREATE PROCEDURE dbo.spMatchups_Update + @id int, + @WinnerId int +AS +BEGIN + SET NOCOUNT ON; + + update dbo.Matchups + set WinnerId = @WinnerId + where id = @Id; + +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spPeople_GetAll.sql b/TournamentsDB/dbo/Stored Procedures/spPeople_GetAll.sql new file mode 100644 index 0000000..c0b448d --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spPeople_GetAll.sql @@ -0,0 +1,11 @@ +CREATE PROCEDURE [spPeople_GetAll] + +AS +BEGIN + + SET NOCOUNT ON; + + select * + from People; + +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spPeople_Insert.sql b/TournamentsDB/dbo/Stored Procedures/spPeople_Insert.sql new file mode 100644 index 0000000..d84408d --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spPeople_Insert.sql @@ -0,0 +1,24 @@ + + +-- ============================================= +-- Author: Alejandro +-- Create date: 9/18/2023 +-- Description: Inserts a person in the People tables and returns the id of that record. +-- ============================================= +CREATE PROCEDURE dbo.spPeople_Insert + @FirstName nvarchar(50), + @LastName nvarchar(50), + @EmailAddress nvarchar(50), + @CellPhoneNumber nvarchar(50), + @id int = 0 output + +AS +BEGIN + SET NOCOUNT ON; + + insert into People(FirstName, LastName, EmailAddress, CellPhoneNumber) + values(@FirstName, @LastName, @EmailAddress, @CellPhoneNumber); + + select @id = SCOPE_IDENTITY(); + +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spPrizes_GetByTournament.sql b/TournamentsDB/dbo/Stored Procedures/spPrizes_GetByTournament.sql new file mode 100644 index 0000000..f1d1356 --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spPrizes_GetByTournament.sql @@ -0,0 +1,14 @@ +CREATE PROCEDURE [spPrizes_GetByTournament] + @TournamentId int + +AS +BEGIN + + SET NOCOUNT ON; + + select p.* + from Prizes p + inner join TournamentPrizes t on p.id = t.PrizeId + where t.tournamentId = @TournamentId; + +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spPrizes_Insert.sql b/TournamentsDB/dbo/Stored Procedures/spPrizes_Insert.sql new file mode 100644 index 0000000..10b124d --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spPrizes_Insert.sql @@ -0,0 +1,21 @@ +-- ============================================= +-- Author: Alejandro +-- Create date: 9/10/2023 +-- Description: Inserts a prize in the Prizes tables and returns the id of that record. +-- ============================================= +CREATE PROCEDURE dbo.spPrizes_Insert + @PlaceNumber int, + @PlaceName nvarchar(50), + @PrizeAmount money, + @PrizePercentage float, + @id int = 0 output +AS +BEGIN + SET NOCOUNT ON; + + insert into dbo.Prizes (PlaceNumber, PlaceName, PrizeAmount, PrizePercentage) + values (@PlaceNumber, @PlaceName, @PrizeAmount, @PrizePercentage); + + select @id = SCOPE_IDENTITY(); + +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spTeamMembers_GetByTeam.sql b/TournamentsDB/dbo/Stored Procedures/spTeamMembers_GetByTeam.sql new file mode 100644 index 0000000..1d8c5ff --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spTeamMembers_GetByTeam.sql @@ -0,0 +1,16 @@ +CREATE PROCEDURE [spTeamMembers_GetByTeam] + @TeamId int + +AS +BEGIN + + SET NOCOUNT ON; + + select p.* + from People as p + inner join TeamMembers as tm on p.id = tm.PersonId + inner join Teams as t on tm.TeamId = t.id + where t.id = @TeamId + + +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spTeamMembers_Insert.sql b/TournamentsDB/dbo/Stored Procedures/spTeamMembers_Insert.sql new file mode 100644 index 0000000..91a749a --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spTeamMembers_Insert.sql @@ -0,0 +1,21 @@ + + +-- ============================================= +-- Author: Alejandro +-- Create date: 10/9/2023 +-- Description: Inserts the relation between a team and a team member in the TeamMembers tables +-- and returns the id of that relation. +-- ============================================= +CREATE PROCEDURE dbo.spTeamMembers_Insert + @TeamId int, + @PersonId int, + @id int = 0 output +AS +BEGIN + SET NOCOUNT ON; + + insert into TeamMembers (TeamId,PersonId) + values (@TeamId,@PersonId); + + select @id = SCOPE_IDENTITY(); +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spTeam_GetAll.sql b/TournamentsDB/dbo/Stored Procedures/spTeam_GetAll.sql new file mode 100644 index 0000000..9cd3891 --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spTeam_GetAll.sql @@ -0,0 +1,15 @@ + +-- ============================================= +-- Author: Alejandro +-- Create date: 11/1/2023 +-- Description: Returns all the teams stored in the database. +-- ============================================= +CREATE PROCEDURE dbo.spTeam_GetAll + +AS +BEGIN + SET NOCOUNT ON; + + select * + from dbo.Teams; +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spTeams_GetByTournament.sql b/TournamentsDB/dbo/Stored Procedures/spTeams_GetByTournament.sql new file mode 100644 index 0000000..dfb91e2 --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spTeams_GetByTournament.sql @@ -0,0 +1,14 @@ +CREATE PROCEDURE [spTeams_GetByTournament] + @TournamentId int + +AS +BEGIN + + SET NOCOUNT ON; + + select t.* + from Teams as t + inner join TournamentEntries as e on t.id = e.TeamId + where e.TournamentId = @TournamentId; + +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spTeams_Insert.sql b/TournamentsDB/dbo/Stored Procedures/spTeams_Insert.sql new file mode 100644 index 0000000..229bb22 --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spTeams_Insert.sql @@ -0,0 +1,19 @@ + + +-- ============================================= +-- Author: Alejandro +-- Create date: 10/9/2023 +-- Description: Inserts a team in the Teams tables and returns the id of that record. +-- ============================================= +CREATE PROCEDURE dbo.spTeams_Insert + @TeamName nvarchar(100), + @Id int = 0 output +AS +BEGIN + SET NOCOUNT ON; + + insert into Teams (TeamName) + values (@TeamName); + + select @Id = SCOPE_IDENTITY(); +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spTournamentEntries_Insert.sql b/TournamentsDB/dbo/Stored Procedures/spTournamentEntries_Insert.sql new file mode 100644 index 0000000..bd98f67 --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spTournamentEntries_Insert.sql @@ -0,0 +1,22 @@ + + + +-- ============================================= +-- Author: Alejandro +-- Create date: 12/2/2023 +-- Description: Inserts the relation between a tournament and a team in the TournamentEntries table +-- and returns the id of that relation. +-- ============================================= +CREATE PROCEDURE dbo.spTournamentEntries_Insert + @TournamentId int, + @TeamId int, + @id int = 0 output +AS +BEGIN + SET NOCOUNT ON; + + insert into TournamentEntries(TournamentId,TeamId) + values (@TournamentId,@TeamId); + + select @id = SCOPE_IDENTITY(); +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spTournamentPrizes_Insert.sql b/TournamentsDB/dbo/Stored Procedures/spTournamentPrizes_Insert.sql new file mode 100644 index 0000000..c78ea1a --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spTournamentPrizes_Insert.sql @@ -0,0 +1,22 @@ + + + +-- ============================================= +-- Author: Alejandro +-- Create date: 12/2/2023 +-- Description: Inserts the relation between a tournament and a prize in the TournamentPrizes table +-- and returns the id of that relation. +-- ============================================= +CREATE PROCEDURE dbo.spTournamentPrizes_Insert + @TournamentId int, + @PrizeId int, + @id int = 0 output +AS +BEGIN + SET NOCOUNT ON; + + insert into TournamentPrizes(TournamentId,PrizeId) + values (@TournamentId,@PrizeId); + + select @id = SCOPE_IDENTITY(); +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spTournaments_Complete.sql b/TournamentsDB/dbo/Stored Procedures/spTournaments_Complete.sql new file mode 100644 index 0000000..541ac76 --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spTournaments_Complete.sql @@ -0,0 +1,11 @@ +CREATE PROCEDURE dbo.spTournaments_Complete + @id int +AS +BEGIN + SET NOCOUNT ON; + + update dbo.Tournaments + set Active = 0 + where id = @Id; + +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spTournaments_GetAll.sql b/TournamentsDB/dbo/Stored Procedures/spTournaments_GetAll.sql new file mode 100644 index 0000000..2664ede --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spTournaments_GetAll.sql @@ -0,0 +1,12 @@ +CREATE PROCEDURE [spTournaments_GetAll] + +AS +BEGIN + + SET NOCOUNT ON; + + select * + from Tournaments + where Active=1;; + +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Stored Procedures/spTournaments_Insert.sql b/TournamentsDB/dbo/Stored Procedures/spTournaments_Insert.sql new file mode 100644 index 0000000..47cd9ed --- /dev/null +++ b/TournamentsDB/dbo/Stored Procedures/spTournaments_Insert.sql @@ -0,0 +1,20 @@ + + +-- ============================================= +-- Author: Alejandro +-- Create date: 12/2/2023 +-- Description: Inserts a tournament in the Tournaments table and returns the id of that record. +-- ============================================= +CREATE PROCEDURE dbo.spTournaments_Insert + @TournamentName nvarchar(50), + @EntryFee money, + @id int = 0 output +AS +BEGIN + SET NOCOUNT ON; + + insert into Tournaments(TournamentName,EntryFee,Active) + values (@TournamentName,@EntryFee,1); + + select @id = SCOPE_IDENTITY(); +END \ No newline at end of file diff --git a/TournamentsDB/dbo/Tables/MatchupEntries.sql b/TournamentsDB/dbo/Tables/MatchupEntries.sql new file mode 100644 index 0000000..694403c --- /dev/null +++ b/TournamentsDB/dbo/Tables/MatchupEntries.sql @@ -0,0 +1,12 @@ +CREATE TABLE [dbo].[MatchupEntries] ( + [id] INT IDENTITY (1, 1) NOT NULL, + [MatchupId] INT NOT NULL, + [ParentMatchupId] INT NULL, + [TeamCompetingId] INT NULL, + [Score] INT NULL, + CONSTRAINT [PK_Matchup_Entries] PRIMARY KEY CLUSTERED ([id] ASC), + CONSTRAINT [FK_MatchupEntries_MatchupId] FOREIGN KEY ([MatchupId]) REFERENCES [dbo].[Matchups] ([id]), + CONSTRAINT [FK_MatchupEntries_ParentMatchupId] FOREIGN KEY ([ParentMatchupId]) REFERENCES [dbo].[Matchups] ([id]), + CONSTRAINT [FK_MatchupEntries_TeamCompetingId] FOREIGN KEY ([TeamCompetingId]) REFERENCES [dbo].[Teams] ([id]) +); + diff --git a/TournamentsDB/dbo/Tables/Matchups.sql b/TournamentsDB/dbo/Tables/Matchups.sql new file mode 100644 index 0000000..1a12fb0 --- /dev/null +++ b/TournamentsDB/dbo/Tables/Matchups.sql @@ -0,0 +1,10 @@ +CREATE TABLE [dbo].[Matchups] ( + [id] INT IDENTITY (1, 1) NOT NULL, + [TournamentId] INT NOT NULL, + [WinnerId] INT NULL, + [MatchupRound] INT NOT NULL, + CONSTRAINT [PK_Matchups] PRIMARY KEY CLUSTERED ([id] ASC), + CONSTRAINT [FK_Matchups_TournamentId] FOREIGN KEY ([TournamentId]) REFERENCES [dbo].[Tournaments] ([id]), + CONSTRAINT [FK_Matchups_WinnerId] FOREIGN KEY ([WinnerId]) REFERENCES [dbo].[Teams] ([id]) +); + diff --git a/TournamentsDB/dbo/Tables/People.sql b/TournamentsDB/dbo/Tables/People.sql new file mode 100644 index 0000000..6c5a48c --- /dev/null +++ b/TournamentsDB/dbo/Tables/People.sql @@ -0,0 +1,9 @@ +CREATE TABLE [dbo].[People] ( + [id] INT IDENTITY (1, 1) NOT NULL, + [FirstName] NVARCHAR (100) NOT NULL, + [LastName] NVARCHAR (100) NOT NULL, + [EmailAddress] NVARCHAR (100) NOT NULL, + [CellPhoneNumber] NVARCHAR (100) NULL, + CONSTRAINT [PK_People] PRIMARY KEY CLUSTERED ([id] ASC) +); + diff --git a/TournamentsDB/dbo/Tables/Prizes.sql b/TournamentsDB/dbo/Tables/Prizes.sql new file mode 100644 index 0000000..441cb76 --- /dev/null +++ b/TournamentsDB/dbo/Tables/Prizes.sql @@ -0,0 +1,9 @@ +CREATE TABLE [dbo].[Prizes] ( + [id] INT IDENTITY (1, 1) NOT NULL, + [PlaceNumber] INT NOT NULL, + [PlaceName] NVARCHAR (50) NOT NULL, + [PrizeAmount] MONEY CONSTRAINT [DF_Prizes_PrizeAmount] DEFAULT ((0)) NOT NULL, + [PrizePercentage] FLOAT (53) CONSTRAINT [DF_Prizes_PrizePercentage] DEFAULT ((0)) NOT NULL, + CONSTRAINT [PK_Prizes] PRIMARY KEY CLUSTERED ([id] ASC) +); + diff --git a/TournamentsDB/dbo/Tables/TeamMembers.sql b/TournamentsDB/dbo/Tables/TeamMembers.sql new file mode 100644 index 0000000..9735f69 --- /dev/null +++ b/TournamentsDB/dbo/Tables/TeamMembers.sql @@ -0,0 +1,9 @@ +CREATE TABLE [dbo].[TeamMembers] ( + [id] INT IDENTITY (1, 1) NOT NULL, + [TeamId] INT NOT NULL, + [PersonId] INT NOT NULL, + CONSTRAINT [PK_Team_Members] PRIMARY KEY CLUSTERED ([id] ASC), + CONSTRAINT [FK_TeamMembers_PersonId] FOREIGN KEY ([PersonId]) REFERENCES [dbo].[People] ([id]), + CONSTRAINT [FK_TeamMembers_TeamId] FOREIGN KEY ([TeamId]) REFERENCES [dbo].[Teams] ([id]) +); + diff --git a/TournamentsDB/dbo/Tables/Teams.sql b/TournamentsDB/dbo/Tables/Teams.sql new file mode 100644 index 0000000..b0ceb72 --- /dev/null +++ b/TournamentsDB/dbo/Tables/Teams.sql @@ -0,0 +1,6 @@ +CREATE TABLE [dbo].[Teams] ( + [id] INT IDENTITY (1, 1) NOT NULL, + [TeamName] NVARCHAR (100) NOT NULL, + CONSTRAINT [PK_Teams] PRIMARY KEY CLUSTERED ([id] ASC) +); + diff --git a/TournamentsDB/dbo/Tables/TournamentEntries.sql b/TournamentsDB/dbo/Tables/TournamentEntries.sql new file mode 100644 index 0000000..064e9a2 --- /dev/null +++ b/TournamentsDB/dbo/Tables/TournamentEntries.sql @@ -0,0 +1,9 @@ +CREATE TABLE [dbo].[TournamentEntries] ( + [id] INT IDENTITY (1, 1) NOT NULL, + [TournamentId] INT NOT NULL, + [TeamId] INT NOT NULL, + CONSTRAINT [PK_Tournament_Entries] PRIMARY KEY CLUSTERED ([id] ASC), + CONSTRAINT [FK_TournamentEntries_TeamId] FOREIGN KEY ([TeamId]) REFERENCES [dbo].[Teams] ([id]), + CONSTRAINT [FK_TournamentEntries_TournamentId] FOREIGN KEY ([TournamentId]) REFERENCES [dbo].[Tournaments] ([id]) +); + diff --git a/TournamentsDB/dbo/Tables/TournamentPrizes.sql b/TournamentsDB/dbo/Tables/TournamentPrizes.sql new file mode 100644 index 0000000..223f4d2 --- /dev/null +++ b/TournamentsDB/dbo/Tables/TournamentPrizes.sql @@ -0,0 +1,9 @@ +CREATE TABLE [dbo].[TournamentPrizes] ( + [id] INT IDENTITY (1, 1) NOT NULL, + [TournamentId] INT NOT NULL, + [PrizeId] INT NOT NULL, + CONSTRAINT [PK_Tournament_Prizes] PRIMARY KEY CLUSTERED ([id] ASC), + CONSTRAINT [FK_TournamentPrizes_PrizeId] FOREIGN KEY ([PrizeId]) REFERENCES [dbo].[Prizes] ([id]), + CONSTRAINT [FK_TournamentPrizes_TournamentId] FOREIGN KEY ([TournamentId]) REFERENCES [dbo].[Tournaments] ([id]) +); + diff --git a/TournamentsDB/dbo/Tables/Tournaments.sql b/TournamentsDB/dbo/Tables/Tournaments.sql new file mode 100644 index 0000000..6328acf --- /dev/null +++ b/TournamentsDB/dbo/Tables/Tournaments.sql @@ -0,0 +1,8 @@ +CREATE TABLE [dbo].[Tournaments] ( + [id] INT IDENTITY (1, 1) NOT NULL, + [TournamentName] NVARCHAR (50) NOT NULL, + [EntryFee] MONEY CONSTRAINT [DF_Tournaments_EntryFee] DEFAULT ((0)) NOT NULL, + [Active] BIT NOT NULL, + CONSTRAINT [PK_Tournaments] PRIMARY KEY CLUSTERED ([id] ASC) +); +