Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » Mysql »

error #1064 al crear una base de datos..

Estas en el tema de error #1064 al crear una base de datos.. en el foro de Mysql en Foros del Web. Hola, llevo dandole vueltas al asunto bastante tiempo y no consigo saber como estructurar esta base de datos, en esta ultima vez yo pensaba que ...
  #1 (permalink)  
Antiguo 23/03/2006, 18:14
MindPaniC
Invitado
 
Mensajes: n/a
Puntos:
Exclamación error #1064 al crear una base de datos..

Hola,

llevo dandole vueltas al asunto bastante tiempo y no consigo saber como estructurar esta base de datos, en esta ultima vez yo pensaba que todo estaba bien... pero no, me ha dado este error:

Cita:
#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ') TYPE=InnoDB' at line 4
La cosa es que quiero relacionar esas tablas... pero es la primera vez que relaciono tablas y no me ha salido... solo tengo tablas simples por ahora que como os imaginais no sirven para nada....

mi sql es este:

Código:
create table artistas
( artid int unsigned not null auto_increment primary key,
  nombre char(50) not null,
  bio text not null,
  foto char(50) not null,
  web char(80) not null,
  fecha datetime not null default 'No hay datos'
) TYPE=InnoDB;
create table audio_tracks
( trackid int unsigned not null auto_increment primary key,
  artid int unsigned not null,
  estiloid int unsigned not null,
  nombre char(100),
  url char(120),
  peso float(3,2) not null,
  duracion float(2,2) not null,
  fecha datetime not null,
  INDEX (artid),
  INDEX (estiloid),
  FOREIGN KEY (artid) REFERENCES artistas(artid),
  FOREIGN KEY (estiloid) REFERENCES estilos(estiloid)
) TYPE=InnoDB;
create table sets
( setid int unsigned not null auto_increment primary key,
  artid int unsigned not null,
  estiloid int unsigned not null,
  nombre char(100),
  url char(120),
  peso float(3,2) not null,
  duracion float(2,2) not null,
  fecha datetime not null,
  INDEX (artid),
  INDEX (estiloid),
  FOREIGN KEY (artid) REFERENCES artistas(artid),
  FOREIGN KEY (estiloid) REFERENCES estilos(estiloid)
) TYPE=InnoDB;
create table estilos
( estiloid int unsigned not null auto_increment primary key,
  estilo char(50) not null,
) TYPE=InnoDB;
¿como debo relacionar estas tablas?
  #2 (permalink)  
Antiguo 23/03/2006, 21:07
Avatar de claudiovega  
Fecha de Ingreso: octubre-2003
Ubicación: Puerto Montt
Mensajes: 3.667
Antigüedad: 20 años, 5 meses
Puntos: 11
Dejalo así:

Código:
create table artistas
( artid int unsigned not null auto_increment primary key,
  nombre char(50) not null,
  bio text not null,
  foto char(50) not null,
  web char(80) not null,
  fecha datetime not null default '0000-00-00'
) TYPE=InnoDB;
create table estilos
( estiloid int unsigned not null auto_increment primary key,
  estilo char(50) not null
) TYPE=InnoDB;
create table audio_tracks
( trackid int unsigned not null auto_increment primary key,
  artid int unsigned not null,
  estiloid int unsigned not null,
  nombre char(100),
  url char(120),
  peso float(3,2) not null,
  duracion float(2,2) not null,
  fecha datetime not null,
  INDEX (artid),
  INDEX (estiloid),
  FOREIGN KEY (artid) REFERENCES artistas(artid),
  FOREIGN KEY (estiloid) REFERENCES estilos(estiloid)
) TYPE=InnoDB;
create table sets
( setid int unsigned not null auto_increment primary key,
  artid int unsigned not null,
  estiloid int unsigned not null,
  nombre char(100),
  url char(120),
  peso float(3,2) not null,
  duracion float(2,2) not null,
  fecha datetime not null,
  INDEX (artid),
  INDEX (estiloid),
  FOREIGN KEY (artid) REFERENCES artistas(artid),
  FOREIGN KEY (estiloid) REFERENCES estilos(estiloid)
) TYPE=InnoDB;
  #3 (permalink)  
Antiguo 24/03/2006, 06:31
MindPaniC
Invitado
 
Mensajes: n/a
Puntos:
Gracias claudio... como veo era un simple error de sintasix.

al final lo he dejado asi:
Cita:
create table artistas
( artid int unsigned not null auto_increment primary key,
nombre char(50) not null,
bio text not null,
foto char(50) not null,
web char(80) not null default 'No hay datos',
fecha datetime not null
) TYPE=InnoDB;

create table estilos
( estiloid int unsigned not null auto_increment primary key,
estilo char(50) not null
) TYPE=InnoDB;

create table audio_tracks
( trackid int unsigned not null auto_increment,
artid int unsigned not null,
estiloid int unsigned not null,
nombre char(100),
url char(120),
peso float(3,2) not null,
duracion float(2,2) not null,
fecha datetime not null,
clics mediumint(10) unsigned NOT NULL default '0',
urlcriticas varchar(100) NOT NULL default '',
primary key (trackid, artid),
INDEX (artid),
INDEX (estiloid),
FOREIGN KEY (artid) REFERENCES artistas(artid),
FOREIGN KEY (estiloid) REFERENCES estilos(estiloid)
) TYPE=InnoDB;

create table sets
( setid int unsigned not null auto_increment,
artid int unsigned not null,
estiloid int unsigned not null,
nombre char(100),
url char(120),
peso float(3,2) not null,
duracion float(2,2) not null,
fecha datetime not null,
clics mediumint(10) unsigned NOT NULL default '0',
urlcriticas varchar(100) NOT NULL default '',
primary key (setid, artid),
INDEX (artid),
INDEX (estiloid),
FOREIGN KEY (artid) REFERENCES artistas(artid),
FOREIGN KEY (estiloid) REFERENCES estilos(estiloid)
) TYPE=InnoDB;
ha funcionado, ahora me toca introducir datos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:36.