Ok, so I have designed a website so that my buddies and I can keep track of all our friendly bets online. I'm trying to learn relational database structures in the process. So, here was my first design.
2 tables
---- USERS----------------------------------------------
EMAIL(key) | password | username | groupname | notify |
----------------------------------------------------------
groupname is so only users with the same groupname are displayed on the table views
notify - value of yes or no whether they want email notifications
----------------betsTable---------------------------------------------------
bet description | bet between | amount | winner | betId (key)| betCreator | date of bet
--------------------------------------------------------------------------------
So, after doing my homework I found there are some repetition issues with this design. I have gone through a few books and tutorials and have revised my tables. Please can all you database experts give me opinoins on if this design is better.
BetsTable
------------------------------------------------------------------
betId (key) | nameBet | amount | dateOfBet
-------------------------------------------------------------------
winner_betId
-----------------------------
betId(pk) | winner
---------------------------
betBetween_betId
---------------------------------
betId(pk) | betBetween
---------------------------------
betCreator_betId
--------------------------------
betId(pk) | betCreator
--------------------------------
users
------------------------------------------------------------------------------------------
user_id(pk) | email (unique) | username (unique) | password (unique) | notify enum(yes,no)
------------------------------------------------------------------------------------------
groupnames
-------------------------------
id(pk) | groupname (unique)
-------------------------------
user_id_groupnames
------------------------------
user_id(pk) | groupname(unique)
-------------------------------
old design of betstable
-----------------------------------------------------------------------------------------
nameBet betBetween amount winner betId (pk) betCreator dateOfBet
test Open 5 steve 1 ken 24-Apr-2008
test1 ken 4 ken 2 steve 02-Apr-2008
test 2 ken 4 steve 3 steve 02-Apr-2008
testy Open 45 ken 4 steve 02-Apr-2008
ffffff steve 23456 steve 5 ken 05-Apr-2008
-----------------------------------------------------------------------------------------
old design of users
--------------------------------------------------------------------------------------
email username password groupname notify
test@yahoo.com ty molli group1 no
test2@yahoo.com jony361 ytrtyuu8 group2 no
test3@yahoo.com tyhgf vvvvv group1 yes
--------------------------------------------------------------------------------------