[sql] Test
Viewer
- CREATE DATABASE `Test`;
- CREATE TABLE `Players` (
- `ID_Player` INT(11) NOT NULL,
- `name` INT(11) DEFAULT NULL,
- `initials` VARCHAR(1) DEFAULT NULL,
- `year_birth` INT(4) DEFAULT NULL,
- `sex` VARCHAR(1) DEFAULT NULL,
- `year_joined` INT(4) DEFAULT NULL,
- `street` VARCHAR(30) DEFAULT NULL,
- `house_num` VARCHAR(4) DEFAULT NULL,
- `postcode` VARCHAR(6) DEFAULT NULL,
- `town` VARCHAR(30) DEFAULT NULL,
- `phone` VARCHAR(12) DEFAULT NULL,
- `id_league` INT(4) DEFAULT NULL,
- PRIMARY KEY (`ID_Player`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
- INSERT INTO `Players` (`ID_Player`, `name`, `initials`,`year_birth`,`sex`,`year_joined`,`street`,`house_num`,`postcode`,`town`,`phone`,`id_league`) VALUES
- (2,"Sturaro","R",1978,"M",2005,"Corso Italia","43","3575NH","Milano","070-237893",2411),
- (6,"Pjanix","R",1978,"M",1994,"Via Torino","80","1234KK","Milano","070-237893",8467),
- (8,"Alex Sandro","B",1992,"F",2010,"Corso Libertà","4","6584WO","Roma","070-237893",2983),
- (27,"Cuadrado","DD",1994,"F",2013,"Via Del Corso","804","8457DK","Como","070-237893",2513),
- (44,"Buffon","E",1993,"M",2010,"Via Del Corso","804","8457DK","Roma","070-237893",1124),
- (18,"Bonucci","M",2001,"F",2015,"Via Del Corso","804","8457DK","Milano","070-237893",6409),
- (83,"Higuain","PK",1986,"M",2012,"Via Del Corso","804","8457DK","Milano","070-237893",1608),
- (100,"Pianic","P",1993,"M",2009,"Via Del Corso","804","8457DK","Milano","070-237893",6524),
- (104,"Matudi","D",2000,"F",2014,"Via Del Corso","804","8457DK","Como","070-237893",7060),
- (112,"Barzagli","IP",1993,"F",2014,"Via Del Corso","804","8457DK","Napoli","070-237893",1319);
- INSERT INTO `Players` (`ID_Player`, `name`, `initials`,`year_birth`,`sex`,`year_joined`,`street`,`house_num`,`postcode`,`town`,`phone`) VALUES
- (7,"Howedes","GWS",1993,"M",2011,"Via Tevere","39","9758VB","Milano","070-237893"),
- (28,"Cuadrado","C",1993,"F",2013,"Via Statuto","10","1294QK","Bergamo","070-237893"),
- (39,"Benatia","D",1986,"M",2010,"Piazza Indipendenza","78","9629CD","Milano","070-237893"),
- (95,"Marchisio","P",1964,"M",2002,"Corso Italia","33/a","5746OP","Torino","070-237893");
- -- --------------------------------------------------------
- --
- -- Table structure for table `Teams`
- --
- CREATE TABLE `Teams` (
- `ID_Team` INT(11) NOT NULL,
- FOREIGN KEY (`ID_Player`) REFERENCES Players(`ID_Player`),
- `division` VARCHAR(30) DEFAULT NULL,
- PRIMARY KEY (`ID_Team`),
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
- INSERT INTO `Teams` (`ID_Team`, `ID_player`, `division`) VALUES
- (1,6,"First"),
- (2,27,"Second");
- -- --------------------------------------------------------
- --
- -- Table structure for table `Games`
- --
- CREATE TABLE `Games` (
- FOREIGN KEY (`ID_Team`) REFERENCES Teams(`ID_Team`) ,
- FOREIGN KEY (`ID_Player`) REFERENCES Players(`ID_Player`),
- `won` INT(11) DEFAULT NULL,
- `lost` INT(11) DEFAULT NULL
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
- INSERT INTO `Games` (`ID_Team`, `ID_player`, `won`, `lost`) VALUES
- (1, 2, 4, 8),
- (1, 6, 9, 1),
- (1, 8, 0, 1),
- (1, 44, 7, 5),
- (1, 18, 5, 0),
- (1, 83, 3, 3),
- (2, 8, 4, 4),
- (2, 27, 11, 2),
- (2, 104, 8, 4),
- (2, 112, 4, 8);
- -- --------------------------------------------------------
- --
- -- Table structure for table `Penalties`
- --
- CREATE TABLE `Penalties` (
- `ID_Payment` INT(11) NOT NULL AUTO_INCREMENT,
- FOREIGN KEY (`ID_Player`) REFERENCES Players(`ID_Player`) ,
- `pdate` VARCHAR(10) DEFAULT NULL,
- `amount` INT(11) DEFAULT NULL,
- PRIMARY KEY (`ID_Payment`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
- INSERT INTO `Penalties` (`ID_Payment`, `ID_player`, `pdate`, `amount`) VALUES
- (1,6,"08/12/2010",1000),
- (2,44,"05/05/2011",750),
- (3,27,"10/09/2013",1000),
- (4,104,"08/12/2014",500),
- (5,44,"08/12/2010",250),
- (6,8,"08/12/2010",250),
- (7,44,"30/12/2012",300),
- (8,27,"12/11/2014",750);
Editor
You can edit this paste and save as new:
File Description
- Test
- Paste Code
- 01 Mar-2021
- 3.77 Kb
You can Share it:
Latest Code Pastes