0% found this document useful (0 votes)
20 views3 pages

Cycle 0

Uploaded by

NIVEDH P
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views3 pages

Cycle 0

Uploaded by

NIVEDH P
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

mysql> use 22b009

Database changed
mysql> use 22b009;
Database changed
mysql> create table Matches (
MatchID int primary key,Team1 varchar(50),
Team2 varchar(50),Ground varchar(50),Date date,Winner varchar(50));
Query OK, 0 rows affected (0.31 sec)

mysql> desc Matches;


+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| MatchID | int(11) | NO | PRI | NULL | |
| Team1 | varchar(50) | YES | | NULL | |
| Team2 | varchar(50) | YES | | NULL | |
| Ground | varchar(50) | YES | | NULL | |
| Date | date | YES | | NULL | |
| Winner | varchar(50) | YES | | NULL | |
+---------+-------------+------+-----+---------+-------+
6 rows in set (0.01 sec)

mysql> insert into Matches values(


1,"England","South Africa","The Oval","2019-05-30","England");
Query OK, 1 row affected (0.05 sec)

mysql> insert into Matches values(


2,"Pakistan","West Indies","Nottingham","2019-05-31","West Indies");
Query OK, 1 row affected (0.04 sec)

mysql> insert into Matches values(


3,"Sri Lanka","New Zealand","Cardiff","2019-06-01","New Zealand");
Query OK, 1 row affected (0.08 sec)

mysql> insert into Matches values(


4,"Afghanistan","Australia","Bristol","2019-06-01","Australia");
Query OK, 1 row affected (0.07 sec)

mysql> insert into Matches values(5,"India","Australia","Madras","2019-06-


03","Australia");
Query OK, 1 row affected (0.05 sec)

mysql> select * from Matches;


+---------+-------------+--------------+------------+------------+-------------+
| MatchID | Team1 | Team2 | Ground | Date | Winner |
+---------+-------------+--------------+------------+------------+-------------+
| 1 | England | South Africa | The Oval | 2019-05-30 | England |
| 2 | Pakistan | West Indies | Nottingham | 2019-05-31 | West Indies |
| 3 | Sri Lanka | New Zealand | Cardiff | 2019-06-01 | New Zealand |
| 4 | Afghanistan | Australia | Bristol | 2019-06-01 | Australia |
| 5 | India | Australia | Madras | 2019-06-03 | Australia |
+---------+-------------+--------------+------------+------------+-------------+
5 rows in set (0.00 sec)

mysql> create table Player (


PlayerID int primary key,Name varchar(50),
Country varchar(50),YBorn int,BPlace varchar(50),FirstMatch int);
Query OK, 0 rows affected (0.25 sec)
mysql> desc Player;
+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| PlayerID | int(11) | NO | PRI | NULL | |
| Name | varchar(50) | YES | | NULL | |
| Country | varchar(50) | YES | | NULL | |
| YBorn | int(11) | YES | | NULL | |
| BPlace | varchar(50) | YES | | NULL | |
| FirstMatch | int(11) | YES | | NULL | |
+------------+-------------+------+-----+---------+-------+
6 rows in set (0.00 sec)

mysql> insert into Player values(


1,"Hardik Pandya","India",1995,"Mumbai",2013);
Query OK, 1 row affected (0.04 sec)

mysql> insert into Player values(


2,"David Warner","Australia",1992,"Sydney",2010);
Query OK, 1 row affected (0.03 sec)

mysql> insert into Player values(


3,"Ben Stokes","England",1992,"London",2010);
Query OK, 1 row affected (0.05 sec)

mysql> insert into Player values(


4,"Babar Azam","Pakistan",1994,"Lahore",2012);
Query OK, 1 row affected (0.04 sec)

mysql> select * from Player;


+----------+---------------+-----------+-------+--------+------------+
| PlayerID | Name | Country | YBorn | BPlace | FirstMatch |
+----------+---------------+-----------+-------+--------+------------+
| 1 | Hardik Pandya | India | 1995 | Mumbai | 2013 |
| 2 | David Warner | Australia | 1992 | Sydney | 2010 |
| 3 | Ben Stokes | England | 1992 | London | 2010 |
| 4 | Babar Azam | Pakistan | 1994 | Lahore | 2012 |
+----------+---------------+-----------+-------+--------+------------+
4 rows in set (0.00 sec)

mysql> create table Batting (


MatchID int,PID int,NRuns int,Average float(10),primary key(MatchID,PID),
foreign key (MatchID) references Matches(MatchID),
foreign key (PID) references Player(PlayerID));
Query OK, 0 rows affected (0.25 sec)

mysql> desc Batting;


+---------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------+------+-----+---------+-------+
| MatchID | int(11) | NO | PRI | NULL | |
| PID | int(11) | NO | PRI | NULL | |
| NRuns | int(11) | YES | | NULL | |
| Average | float | YES | | NULL | |
+---------+---------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> insert into Batting values(1,3,76,76.0);


Query OK, 1 row affected (0.04 sec)
mysql> insert into Batting values(2,4,56,48.1);
Query OK, 1 row affected (0.04 sec)

mysql> insert into Batting values(4,2,156,156);


Query OK, 1 row affected (0.05 sec)

mysql> select * from Batting;


+---------+-----+-------+---------+
| MatchID | PID | NRuns | Average |
+---------+-----+-------+---------+
| 1 | 3 | 76 | 76 |
| 2 | 4 | 56 | 48.1 |
| 4 | 2 | 156 | 156 |
+---------+-----+-------+---------+
3 rows in set (0.00 sec)

mysql> create table Bowling (


MatchID int, PID int,NOvers float(10),NMaidens int,NRuns int,NWickets int,
primary key(MatchID,PID),foreign key (MatchID) references Matches(MatchID),
foreign key (PID) references Player(PlayerID));
Query OK, 0 rows affected (0.33 sec)

mysql> desc Bowling;


+----------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------+------+-----+---------+-------+
| MatchID | int(11) | NO | PRI | NULL | |
| PID | int(11) | NO | PRI | NULL | |
| NOvers | float | YES | | NULL | |
| NMaidens | int(11) | YES | | NULL | |
| NRuns | int(11) | YES | | NULL | |
| NWickets | int(11) | YES | | NULL | |
+----------+---------+------+-----+---------+-------+
6 rows in set (0.00 sec)

mysql> insert into Bowling values (1,3,8.3,1,45,2),(4,2,2.0,0,10,1);


Query OK, 2 rows affected (0.04 sec)
Records: 2 Duplicates: 0 Warnings: 0

mysql> insert into Bowling values(2,4,2.0,0,10,0);


Query OK, 1 row affected (0.04 sec)

mysql> select * from Bowling;


+---------+-----+--------+----------+-------+----------+
| MatchID | PID | NOvers | NMaidens | NRuns | NWickets |
+---------+-----+--------+----------+-------+----------+
| 1 | 3 | 8.3 | 1 | 45 | 2 |
| 2 | 4 | 2 | 0 | 10 | 0 |
| 4 | 2 | 2 | 0 | 10 | 1 |
+---------+-----+--------+----------+-------+----------+
3 rows in set (0.00 sec)

You might also like