Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DATA BASE I need to solve this queries in SQL, Given the follow schema: Users Attribute Description UID: Unique identifier for this user Name: Username

DATA BASE I need to solve this queries in SQL,

Given the follow schema:

Users Attribute Description UID: Unique identifier for this user Name: Username for this user Title: Title for this user (GM = Grandmaster, etc.) Created: When this users account was created ClassicalRating: This users rating in classical games (25 minutes long or more) BlitzRating: This users rating in blitz games (5 minutes long or more) BulletRating: This users rating in bullet games (less than 5 minutes)

Games Attribute Description GID: Unique identifier for this game White: ser ID for the white player Black: User ID for the black player GameType: Type of game (e.g., Rated Classical game) Played: When the game was played TimeLimit: Time limit for the game, in seconds TimeIncrement: Amount of time each player gains on the clock when they make a move, in seconds Opening: Name of the opening moves played in the game Winner: Winner of the game (W: white, B: black, D: draw) Ending: Why the game ended (Checkmate, Resign, Time, or Draw)

Moves Attribute Description GID: ID for the game this move was played in MoveNo: Move number for this move Player: Which player played this move (W: white, B: black) Move: Description of the move in Standard Algebraic Notation CREATE TABLE Users(UID INTEGER PRIMARY KEY, Name VARCHAR(30), Title VARCHAR(3), Created TIMESTAMP(0), ClassicalRating INTEGER, BlitzRating INTEGER, BulletRating INTEGER);

CREATE TABLE Games(GID INTEGER PRIMARY KEY, White INTEGER REFERENCES Users NOT NULL, Black INTEGER REFERENCES Users NOT NULL, GameType VARCHAR(30), Played TIMESTAMP(0), TimeLimit INTEGER, TimeIncrement INTEGER, Opening VARCHAR(100), Winner CHAR(1), Ending VARCHAR(10));

CREATE TABLE Moves(GID INTEGER REFERENCES Games ON DELETE CASCADE, MoveNo INTEGER, Player CHAR(1), Move VARCHAR(10), CONSTRAINT move_pk PRIMARY KEY(GID, MoveNo, Player));

Queries:

6. How many games ended in less than 30 moves?

8. How many pawn moves did players with classical rating of 2000 or more make as white? Pawn moves start with a lower case letter a through h.

9. How many pawn moves did players with classical rating of 2000 or more make, in total? Pawn moves start with a lower case letter a through h.

10. How many games did white win when black didnt castle? Castling is denoted O-O (king side) or O-O-O (queen side), and may sometimes have !, ?, +, or # at the end (good move, bad move, check, and checkmate, respectively)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions