Question: CREATE SCHEMA sch _ rps; SET SEARCH _ PATH TO sch _ rps; / * To support our discussion of Database Administration, we will develop
CREATE SCHEMA schrps;
SET SEARCHPATH TO schrps;
To support our discussion of Database Administration, we will develop
a simple DB application that implements basic data security. It's a
trivially simple game called "Rock, Paper, Scissors" RPS It has many
variations; however, in its simplest form, valid input consists of the
characters RP and SR beats S; S beats P; and P beats
RThis exercise is found in many elementary programming textbooks.
To implement this game securely we will use four tables... OK three related
tables and an errata log The three tables will represent "players", "games",
and "rounds".
A player will have a user ID that shall be required and unique. Hint: that's
a sure bet for a PRIMARY KEY! It also has a date of creation doc that
defaults to NOW We might add some fields as we develop the application;
however, these two will get us started... keep it simple for now.
A game has a required and unique integer lets make it be a BIGINT a doc,
DEFAULT NOW and two different user ids from the players table foreign
keys
The pair Ill call mine P and P must be unique irrespective of order. This
means that, if we have the pair: Al 'Bob' we cannot allow BobAl
and visa versa. The best way to do this is with two constraints on the table:
UNIQUEp p
CHECKp p
I see four fields and five constraints: one PK two FK and the two above.
A round will have a unique & required BIGINT PK obviously a required
game ID referencing the games table, a doc, and two CHAR game tokens
that must be RP or S exclusively... means NOT NULL
The errata table is simple. It's just a log table.
Use this one. It will work for our needs.
DROP TABLE IF EXISTS tblerrata
fldtime TIMESTAMP,
fldSQLSTATE CHAR
fldSQLERRM TEXT
;
Follow the naming conventions given below:
Discussing naming convention and format: VERY IMPORTANT!
Consider a table representing parents. A parent has a unique and required
name, a date of creation, and an optional integer "age" for demo, only.
No database person would store a person's age! It would be calculated
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
