Modifications in table [closed]

1
-- phpMyAdmin SQL Dump
-- version 4.7.9
-- https://www.phpmyadmin.net/
--
-- Servidor: localhost:3306
-- Tiempo de generación: 20-07-2018 a las 10:11:28
-- Versión del servidor: 10.2.16-MariaDB
-- Versión de PHP: 7.1.17

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Base de datos: 'u743999068_mm'
--

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla 'citas'
--

CREATE TABLE 'citas' (
  'id_cita' int(11) NOT NULL DEFAULT 0,
  'nombre_cita' varchar(150) NOT NULL,
  'ok' int(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla 'horarios'
--

CREATE TABLE 'horarios' (
  'id' int(11) NOT NULL,
  'horas' varchar(20) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  'Cliente' varchar(30) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  'dia' int(2) DEFAULT NULL,
  'mes' int(2) DEFAULT NULL,
  'anyo' int(4) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--


--
-- Estructura de tabla para la tabla 'Noticias'
--

CREATE TABLE 'Noticias' (
  'id_noticias' int(11) NOT NULL,
  'tipo_noticia' int(2) NOT NULL,
  'page_heading' varchar(80) NOT NULL,
  'secondary_text' varchar(100) NOT NULL,
  'post_title' varchar(25) NOT NULL,
  'text' varchar(250) NOT NULL,
  'text2' varchar(6000) NOT NULL,
  'text3' varchar(4000) NOT NULL,
  'text4' varchar(3000) NOT NULL,
  'fecha' varchar(30) NOT NULL,
  'user_pub' varchar(30) NOT NULL,
  'foto1' varchar(100) NOT NULL,
  'foto2' varchar(100) NOT NULL,
  'foto3' varchar(100) NOT NULL,
  'foto4' varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla 'Proyectos'
--

CREATE TABLE 'Proyectos' (
  'id_proyecto' int(11) NOT NULL,
  'titulo' varchar(80) NOT NULL,
  'foto' varchar(100) NOT NULL,
  'fecha' varchar(30) NOT NULL,
  'texto1' varchar(250) NOT NULL,
  'texto2' varchar(2000) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;




-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla 'Usuarios'
--

CREATE TABLE 'Usuarios' (
  'id' int(11) NOT NULL,
  'name' varchar(255) NOT NULL,
  'email' varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  'password' varchar(255) DEFAULT NULL,
  'status' int(11) NOT NULL DEFAULT 1,
  'kind' int(11) NOT NULL DEFAULT 0,
  'created_at' datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;




--
-- Indices de la tabla 'citas'
--
ALTER TABLE 'citas'
  ADD PRIMARY KEY ('id_cita');

--
-- Indices de la tabla 'horarios'
--
ALTER TABLE 'horarios'
  ADD PRIMARY KEY ('id');

--
-- Indices de la tabla 'Noticias'
--
ALTER TABLE 'Noticias'
  ADD PRIMARY KEY ('id_noticias');

--
-- Indices de la tabla 'Proyectos'
--
ALTER TABLE 'Proyectos'
  ADD PRIMARY KEY ('id_proyecto');

--
-- Indices de la tabla 'Usuarios'
--
ALTER TABLE 'Usuarios'
  ADD PRIMARY KEY ('id'),
  ADD UNIQUE KEY 'email' ('email');

--
-- AUTO_INCREMENT de las tablas volcadas
--

--
-- AUTO_INCREMENT de la tabla 'horarios'
--
ALTER TABLE 'horarios'
  MODIFY 'id' int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=122;

--
-- AUTO_INCREMENT de la tabla 'Noticias'
--
ALTER TABLE 'Noticias'
  MODIFY 'id_noticias' int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT de la tabla 'Proyectos'
--
ALTER TABLE 'Proyectos'
  MODIFY 'id_proyecto' int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT de la tabla 'Usuarios'
--
ALTER TABLE 'Usuarios'
  MODIFY 'id' int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;

--
-- Restricciones para tablas volcadas
--

--
-- Filtros para la tabla 'citas'
--
ALTER TABLE 'citas'
  ADD CONSTRAINT 'id_cita' FOREIGN KEY ('id_cita') REFERENCES 'horarios' ('id');
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

I would like to see if this database can be improved, and add a relationship between the schedules table and users by means of an intermediate table called appointments.

When a user registers, the data is stored in the Users table. Once you log in, you can request appointments. A schedule is displayed and you select a date, which is saved in the timetable table. And the id and Client field of the table schedules are saved in the table as citations id_cita and nombre_cita respectively.

If the user does not cancel the appointment, and the day of the appointment arrives, this way I keep a table that saves the user, that I can call Client since he / she has attended the appointment. I do not know if the approach is better understood. I consider the table appointments as an intermediate table between users and schedules. The other tables have no relation to any, since they are independent things.

    
asked by Juan Luis Miras Moreno 20.07.2018 в 12:21
source

0 answers