mysql fix and adding some data

This commit is contained in:
2023-04-27 08:37:56 +02:00
parent e8866f68a2
commit 6c7f9c6007

View File

@@ -6,38 +6,65 @@ use Progetto152;
create table if not exists Location create table if not exists Location
( (
id int auto_increment not null, location varchar(255) not null unique,
location varchar(255) not null unique, region varchar(3) not null,
region varchar(3) not null, lat double not null,
lat double not null, lon double not null,
lon double not null, primary key (location)
primary key (id)
); );
create table if not exists Waypoints create table if not exists Waypoints
( (
id int not null auto_increment, id int not null auto_increment,
name varchar(10) not null, name varchar(255) not null,
lat double not null, lat double not null,
lon double not null, lon double not null,
description varchar(1000) not null, description varchar(1000) not null,
img varchar(1000) not null, img varchar(1000) not null,
LocationId int not null, locationName varchar(255) not null,
primary key (id), primary key (id),
foreign key (LocationId) references Location (id) foreign key (LocationName) references Location (location)
); );
create table if not exists User( create table if not exists User
id int not null auto_increment, (
name varchar(45) not null, id int not null auto_increment,
username varchar(100) not null, name varchar(45) not null,
password varchar(100) not null, username varchar(100) not null,
primary key (id) password varchar(100) not null,
primary key (id)
); );
create table if not exists LocationVisited( create table if not exists WaypointsVisited
userId int not null, (
locationid int not null, userId int not null,
foreign key (userId) references User(id), waypointId int not null,
foreign key (locationid) references Location(id) foreign key (userId) references User (id),
) foreign key (waypointId) references Waypoints (id)
);
#popolate table location
insert into Location (location, region, lat, lon)
values ('Biasca', 'TI', 46.361184, 8.970937);
insert into Location (location, region, lat, lon)
values ('Bellinzona', 'TI', 46.194034, 9.023976);
insert into Location (location, region, lat, lon)
values ('Lugano', 'TI', 46.003677, 8.951052);
insert into Location (location, region, lat, lon)
values ('Locarno', 'TI', 46.170794, 8.799534);
insert into Location (location, region, lat, lon)
values ('Ascona', 'TI', 46.157320, 8.773882);
insert into Waypoints (name, lat, lon, description, img, LocationName)
values ('Cascata Santa Petronilla', 46.35328215446709, 8.97758397155138, 'A',
'https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png', 'Biasca');
insert into Waypoints (name, lat, lon, description, img, LocationName)
values ('Casa Küng', 46.363570208549994, 8.963464722308554, 'Descrizione del punto 2',
'https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png',
'Biasca');
insert into Waypoints (name, lat, lon, description, img, LocationName) values ('Punto 1', 46.123,
8.123,
'Descrizione del punto 3, un grandissimo',
'https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png',
'Lugano');