KnowledgeBoat Logo

Informatics Practices

Your school management has decided to organize cricket matches between students of Classes XI and XII. All the students are divided into four teams—Team Rockstars, Team BigGamers, Team Magnet and Team Current. During the summer vacations, various matches are to be held between these teams. Help your sports teacher do the following:

(a) Create a database "Sports" and open it for creating table.

(b) Create a table "Team" with the following considerations:

  1. It should have a column TeamID for storing an integer value between 1 and 9, which refers to unique identification of a team.
  2. Each TeamID should have its associated name (TeamName), which should be a string of length not less than 10 characters.
  3. Give the statement to make TeamID the primary key.

(c) Show the structure of the table Team using SQL command.

(d) As per the preferences of the students, four teams were formed as given below.

Insert these four rows in Team table:

Row 1: (1, Team Rockstars)
Row 2: (2, Team BigGamers)
Row 3: (3, Team Magnet)
Row 4: (4, Team Current)

(e) Display the table Team.

Relational Database

2 Likes

Answer

(a)

CREATE DATABASE SPORTS;
USE SPORTS;

(b)

CREATE TABLE TEAM(TEAMID INT(9) Primary key, TEAMNAME VARCHAR(30));

(c)

DESC TEAM;
Output
+----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| TEAMID   | int         | NO   | PRI | NULL    |       |
| TEAMNAME | varchar(30) | YES  |     | NULL    |       |
+----------+-------------+------+-----+---------+-------+

(d)

INSERT INTO TEAM VALUES(1, "TEAM ROCKSTARS");
INSERT INTO TEAM VALUES(2, "TEAM BIGGAMERS");
INSERT INTO TEAM VALUES(3, "TEAM MAGNET");
INSERT INTO TEAM VALUES(4, "TEAM CURRENT");

(e)

SELECT * FROM TEAM;
Output
+--------+----------------+
| TEAMID | TEAMNAME       |
+--------+----------------+
|      1 | TEAM ROCKSTARS |
|      2 | TEAM BIGGAMERS |
|      3 | TEAM MAGNET    |
|      4 | TEAM CURRENT   |
+--------+----------------+

Answered By

2 Likes


Related Questions