मराठी

Suppose your school management has decided to conduct cricket matches between students of Class XI and Class XII. Students of each class are asked to join any one of the four teams – Team

Advertisements
Advertisements

प्रश्न

Suppose your school management has decided to conduct cricket matches between students of Class XI and Class XII. Students of each class are asked to join any one of the four teams – Team Titan, Team Rockers, Team Magnet, and Team Hurricane. During summer vacations, various matches will be conducted between these teams. Help your sports teacher to do the following:

  1. Create a database “Sports”.
  2. Create a table “TEAM” with the following considerations:
    i) It should have a column TeamID for storing an integer value between 1 to 9, which refers to the unique identification of a team.
    ii) Each TeamID should have its associated name (TeamName), which should be a string of length not less than 10 characters.
  3. Using table level constraint, make TeamID the primary key.
  4. Show the structure of the table TEAM using a SQL statement.
  5. As per the preferences of the students four teams were formed as given below. Insert these four rows in the TEAM table:
    Row 1: (1, Team Titan)
    Row 2: (2, Team Rockers)
    Row 3: (3, Team Magnet)
    Row 3: (4, Team Hurricane)
  6. Show the contents of the table TEAM using a DML statement.
  7. Now create another table MATCH_DETAILS and insert data as shown below. Choose appropriate data types and constraints for each attribute.
  8. Use the foreign key constraint in the MATCH_ DETAILS table with reference to TEAM table so that MATCH_DETAILS table records score of teams existing in the TEAM table only.
Table: MATCH_DETAILS
MatchID MatchDate FirstTeamID SecondTeamID FirstTeamScore SecondTeamScore
M1 2018-07-17 1 2 90 86
M2 2018-07-18 3 4 45 48
M3 2018-07-19 1 3 78 56
M4 2018-07-19 2 4 56 67
M5 2018-07-18 1 4 32 87
M6 2018-07-17 2 3 67 51
थोडक्यात उत्तर
Advertisements

उत्तर

  1. CREATE DATABASE Sports;
  2. CREATE TABLE TEAM (TeamID int (3) Unique, TeamName varchar (30));
  3. ALTER TABLE TEAM ADD Primary key (TeamID);
  4. DESC TEAM;
  5. INSERT INTO TEAM (TeamID, TeamName) VALUES (1, 'Team Titan'), (2, Team Rockers'), (3, Team Magnet'), (4, 'Team Hurricane');
  6. SELECT "FROM TEAM;
  7. CREATE TABLE MATCH DETAILS (MatchID varchar (5) Primary key, MatchDate DATE, First TeamID int (2), Second TeamID int(2), First TeamScore int (5), SecondTeamScore int (5));

    INSERT INTO MATCH-DETAILS (MatchID, MatchDate, First TeamID, SecondTeamID, First TeamScore, Second'TeamScore) VALUES
    ('M1', 2018 - 17 - 17', 1, 2, 90, 86),
    (M2', 2018 - 07 - 18', 3, 4, 45, 48),
    (M3', 2018 - 07 - 19', 1, 3, 78, 56),
    (M4', 2018 - 07 - 19', 2, 4, 56, 67),
    (M5', 2018 - 07 - 20', 1, 4, 32, 87),
    (M6', 2018 - 07 - 21', 2, 3, 67, 51);

  8. ALTER TABLE MATCH_DETAILS ADD FOREIGN KEY(FirstTeamID) REFERENCES TEAM(TeamID);
    ALTER TABLE MATCH_DETAILS ADD FOREIGN KEY(SecondTeamID) REFERENCES TEAM(TeamID);
shaalaa.com
SQL for Data Definition
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 9: Structured Query Language (SQL) - Exercise [पृष्ठ १७८]

APPEARS IN

एनसीईआरटी Computer Science [English] Class 12
पाठ 9 Structured Query Language (SQL)
Exercise | Q 4. | पृष्ठ १७८
एनसीईआरटी Informatics Practices [English] Class 11
पाठ 8 Introduction to Structured Query Language (SQL)
Exercise | Q 5. | पृष्ठ १७१
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×