Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/11/2007, 11:04
yoguuu
 
Fecha de Ingreso: enero-2005
Mensajes: 149
Antigüedad: 19 años, 10 meses
Puntos: 2
Normalización De Tablas

¿Creeis que la normalización de las tablas es aceptable ?
Nombre de la base de datos: "2"
Tablas: "Fechas de nacimiento", "Fechas de registro", "Sexo", "Orientaciones sexuales", "Continentes", "Países", "Comunidades autónomas", "Provincias", "Poblaciones", "Perfiles", "Usuarios".


Posteo una imagen que describe las relaciones en la base de datos:

Código:

CREATE DATABASE `2` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

USE `2`;

CREATE TABLE `Fechas de nacimiento` (
`Id` INT( 9 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`Fecha de nacimiento` DATETIME NOT NULL
) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_unicode_ci;

CREATE TABLE `Fechas de registro` (
`Id` INT( 9 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`Fecha de registro` DATETIME NOT NULL
) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_unicode_ci;

CREATE TABLE `Sexo` (
`Id` INT( 1 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`Sexo` VARCHAR( 6 ) NOT NULL
) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_unicode_ci;

CREATE TABLE `Orientaciones sexuales` (
`Id` INT( 1 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`Orientación sexual` VARCHAR( 50 ) NOT NULL
) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_unicode_ci;

CREATE TABLE `Continentes` (
`Id` INT( 1 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`Continente` VARCHAR( 7 ) NOT NULL
) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_unicode_ci;

CREATE TABLE `Países` (
`Id` INT( 3 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`Id continente` INT( 1 ) UNSIGNED NOT NULL ,
`País` VARCHAR( 50 ) NOT NULL ,
INDEX ( `Id continente` ) ,
FOREIGN KEY ( `Id continente` ) REFERENCES `Continentes` ( `Id` ) ON UPDATE CASCADE ON DELETE CASCADE 
) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_unicode_ci;

CREATE TABLE `Comunidades autónomas` (
`Id` INT( 3 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`Id país` INT( 3 ) UNSIGNED NOT NULL ,
`Comunidad autónoma` VARCHAR( 50 ) NOT NULL ,
INDEX ( `Id país` ) ,
FOREIGN KEY ( `Id país` ) REFERENCES `Países` ( `Id` ) ON UPDATE CASCADE ON DELETE CASCADE 
) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_unicode_ci;

CREATE TABLE `Provincias` (
`Id` INT( 4 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`Id comunidad autónoma` INT( 3 ) UNSIGNED NOT NULL ,
`Provincia` VARCHAR( 50 ) NOT NULL ,
INDEX ( `Id comunidad autónoma` ) ,
FOREIGN KEY ( `Id comunidad autónoma` ) REFERENCES `Comunidades autónomas` ( `Id` ) ON UPDATE CASCADE ON DELETE CASCADE 
) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_unicode_ci;

CREATE TABLE `Poblaciones` (
`Id` INT( 5 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`Id provincia` Int( 4 ) UNSIGNED NOT NULL ,
`Población` VARCHAR( 50 ) NOT NULL ,
INDEX ( `Id provincia` ) ,
FOREIGN KEY ( `Id provincia` ) REFERENCES `Provincias` ( `Id` ) ON UPDATE CASCADE ON DELETE CASCADE 
) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_unicode_ci;

CREATE TABLE `Perfiles` (
`Id` INT( 9 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`Id fecha de nacimiento` INT( 9 ) UNSIGNED NOT NULL ,
`Id fecha de registro` INT( 9 ) UNSIGNED NOT NULL ,
`Id sexo` INT( 1 ) UNSIGNED NOT NULL ,
`Id orientación sexual` INT( 1 ) UNSIGNED NOT NULL ,
`Id continente` INT( 1 ) UNSIGNED NOT NULL ,
`Id país` INT( 3 ) UNSIGNED NOT NULL ,
`Id comunidad autónoma` INT( 3 ) UNSIGNED NOT NULL ,
`Id provincia` INT( 4 ) UNSIGNED NOT NULL ,
`Id población` INT( 5 ) UNSIGNED NOT NULL ,
INDEX ( `Id fecha de nacimiento` ) ,
INDEX ( `Id fecha de registro` ) ,
INDEX ( `Id sexo` ) ,
INDEX ( `Id orientación sexual` ) ,
INDEX ( `Id continente` ) ,
INDEX ( `Id país` ) ,
INDEX ( `Id comunidad autónoma` ) ,
INDEX ( `Id provincia` ) ,
INDEX ( `Id población` ) ,
FOREIGN KEY ( `Id fecha de nacimiento` ) REFERENCES `Fechas de nacimiento` ( `Id` ) ON UPDATE CASCADE ON DELETE CASCADE ,
FOREIGN KEY ( `Id fecha de registro` ) REFERENCES `Fechas de registro` ( `Id` ) ON UPDATE CASCADE ON DELETE CASCADE ,
FOREIGN KEY ( `Id sexo` ) REFERENCES `Sexo` ( `Id` ) ON UPDATE CASCADE ON DELETE CASCADE ,
FOREIGN KEY ( `Id orientación sexual` ) REFERENCES `Orientaciones sexuales` ( `Id` ) ON UPDATE CASCADE ON DELETE CASCADE ,
FOREIGN KEY ( `Id continente` ) REFERENCES `Continentes` ( `Id` ) ON UPDATE CASCADE ON DELETE CASCADE ,
FOREIGN KEY ( `Id país` ) REFERENCES `Países` ( `Id` ) ON UPDATE CASCADE ON DELETE CASCADE ,
FOREIGN KEY ( `Id comunidad autónoma` ) REFERENCES `Comunidades autónomas` ( `Id` ) ON UPDATE CASCADE ON DELETE CASCADE ,
FOREIGN KEY ( `Id provincia` ) REFERENCES `Provincias` ( `Id` ) ON UPDATE CASCADE ON DELETE CASCADE ,
FOREIGN KEY ( `Id población` ) REFERENCES `Poblaciones` ( `Id` ) ON UPDATE CASCADE ON DELETE CASCADE 
) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_unicode_ci;

CREATE TABLE `Usuarios` (
`Id` INT( 9 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`Usuario` VARCHAR( 30 ) NOT NULL ,
`Contraseña` VARCHAR( 30 ) NOT NULL ,
`Email` VARCHAR( 100 ) NOT NULL ,
`Id perfil` INT( 9 ) UNSIGNED NOT NULL ,
INDEX ( `Id perfil` ) ,
FOREIGN KEY ( `Id perfil` ) REFERENCES `Perfiles` ( `Id` ) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_unicode_ci;