Question: Create an ER table and relationship of each entity. Entities and attributes are provided below. Users: user _ id , username, email, password _ hash,
Create an ER table and relationship of each entity. Entities and attributes are provided below.
Users:
userid username, email, passwordhash, balance, registrationdate, status, phonenumber, dateofbirth
Events Basketball Games:
eventid eventname, eventdate, hometeam, awayteam, league, venue, status, season
Teams:
teamid teamname, abbreviation, city, arena, coach
Bets:
betid userid eventid bettype, betamount, odds, betstatus, result, dateplaced
Odds:
oddsid eventid bettype, hometeamodds, awayteamodds, spread, overunder, oddsdate, status
Transactions:
transactionid userid transactiontype, amount, transactiondate, balanceafter, status
Betting History:
historyid userid betid eventid betamount, oddsatbet, result, dateplaced, payout
Promotions:
promotionid promotionname, promotiontype, description, startdate, enddate, minimumbet, status.
SQL of the table are provided below.
Teams table
CREATE TABLE teams
teamid SERIAL PRIMARY KEY,
teamname VARCHAR NOT NULL,
city VARCHAR
createdat TIMESTAMP DEFAULT CURRENTTIMESTAMP
;
Games table
CREATE TABLE games
gameid SERIAL PRIMARY KEY,
hometeamid INTEGER REFERENCES teamsteamid
awayteamid INTEGER REFERENCES teamsteamid
gamedate TIMESTAMP NOT NULL,
hometeamscore INTEGER,
awayteamscore INTEGER,
status VARCHAR Scheduled, Final
createdat TIMESTAMP DEFAULT CURRENTTIMESTAMP
;
Odds table
CREATE TABLE odds
oddsid SERIAL PRIMARY KEY,
gameid INTEGER REFERENCES gamesgameid
bookmakerid INTEGER REFERENCES bookmakersbookmakerid
hometeammoneyline DECIMAL
awayteammoneyline DECIMAL
oddstimestamp TIMESTAMP NOT NULL,
createdat TIMESTAMP DEFAULT CURRENTTIMESTAMP
;
Bookmakers table
CREATE TABLE bookmakers
bookmakerid SERIAL PRIMARY KEY,
bookmakername VARCHAR NOT NULL,
status VARCHAR Active, Inactive
createdat TIMESTAMP DEFAULT CURRENTTIMESTAMP
;
Users table
CREATE TABLE users
userid SERIAL PRIMARY KEY,
username VARCHAR UNIQUE NOT NULL,
email VARCHAR UNIQUE NOT NULL,
passwordhash VARCHAR NOT NULL,
balance DECIMAL DEFAULT
status VARCHAR Active, Suspended
createdat TIMESTAMP DEFAULT CURRENTTIMESTAMP
;
Bets table
CREATE TABLE bets
betid SERIAL PRIMARY KEY,
userid INTEGER REFERENCES usersuserid
gameid INTEGER REFERENCES gamesgameid
oddsid INTEGER REFERENCES oddsoddsid
betamount DECIMAL NOT NULL,
oddsvalue DECIMAL NOT NULL,
potentialpayout DECIMAL NOT NULL,
teamid INTEGER REFERENCES teamsteamid The team bet on to win
status VARCHAR Pending, Won, Lost
placedat TIMESTAMP DEFAULT CURRENTTIMESTAMP,
settledat TIMESTAMP
;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
