Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   SQL (https://www.clubdelphi.com/foros/forumdisplay.php?f=6)
-   -   Consulta en SQL Server (https://www.clubdelphi.com/foros/showthread.php?t=91730)

Snayder187 08-04-2017 10:04:44

Consulta en SQL Server
 
Hola ¿qué tal amigos programadores?

Tengo una consulta, recién me estoy metiendo a temas de programación en SQL SERVER con C# y quisiera hacer un proyecto bueno y un poco grande, de paso practico más. Haré un proyecto sobre "EVENTOS" en Perú-Lima es como festival de fiestas, tengo algunas tablas en mente pero me gustaría leer sus ideas si esta bien o me falta implementar más cosas.

TABLA PERSONAL
- idpersonal
- nombres
- apellidos
- dni
- fecha de nacimiento
- dirección
- telefono
- celular
- estado civil
- estado

- TABLA PROVEEDOR
- TABLA CLIENTES
- TABLA CONTRATO
- TABLA ALQUILER
- TABLA PRECIOS
- TABLA ITEMS
- TABLA COTIZACION
- TABLA EVENTOS
- TABLA REPORTES

Que más tablas puedo hacer y que tablas debo relacionar los FK's, aparte que campos irían en las tablas, espero que me puedan ayudar.

Snayder187 08-04-2017 10:49:09

CREATE DATABASE EVENTOS
GO

USE EVENTOS
GO

TABLE CATEGORIA
- idcategoria int identity(1,1) primary key,
- nom_categoria varchar(100) not null


TABLE TIPO_ITEM
- idtipoitem int identity(1,1) primary key,
- idcategoria int,
- nom_tipoitem varchar(100) not null


TABLE ITEM
- iditem int identity(1,1) primary key,
- idtipoitem int not null,
- des_item varchar(100) not null, << descripcion
- con_item varchar(20) not null, << condicion
- sto_item int not null << stock


TABLE DETALLE_ITEM
- iddetalleitem int identity(1,1) primary key,
- idtipoitem int not null,
- med_detalleitem varchar(50) not null, << medidas
- cap_detalleitem int not null, << capacidad
- dir_detalleitem varchar(100) not null


TABLA PROVEEDOR
- idproveedor int identity(1,1) primary key,
- ruc_proveedor char(11) not null,
- razonsocial_proveedor varchar(100) not null,
- contacto varchar(100) not null,
- celular varchar(12) not null,
- direccion varchar(100) not null,
- telefono varchar(11) null,
- email varchar(80) null,
- estado varchar(1) not null


TABLE PERSONAL
- idpersonal int identity(1,1) primary key
- nom_personal varchar(80) not null,
- ape_personal varchar(100) not null,
- dni_personal varchar(8) not null,
- fna_personal date not null,
- dir_personal varchar(100) not null,
- tel_personal varchar(11) null,
- cel_personal varchar(13) not null,
- esc_personal varchar(25) not null,
- est_personal varchar(1) not null



TABLA PRECIOS

TABLA CONTRATO

TABLA ALQUILER

TABLA CLIENTES

TABLA COTIZACION

TABLA EVENTOS

TABLA REPORTES

Casimiro Notevi 08-04-2017 16:17:05

Bienvenido a clubdelphi, como siempre aconsejamos a los nuevos, no olvides leer nuestra guía de estilo, gracias por tu colaboración :)

Y recuerda poner los tags al código fuente, ejemplo:



Gracias :)

También recuerda poner títulos descriptivos a tus preguntas :)

Neftali [Germán.Estévez] 10-04-2017 12:52:43

El problema es que el diseño de Base de Datos no es una ciencia exacta como las matemáticas.
No hay una tabla se PERSONAL con sus campos y relaciones que sirva para todo. Dependerá de las necesidades que tenga tu programa, de lo que quieras hacer, de lo que quieras almacenar, etc, etc, etc,...

No hay una fórmula que poniendo: "proyecto sobre EVENTOS" te devuelva los campos.

Tampoco sabemos para qué sirve la tabla de CATEGORIA, por ponerte un ejemplo o qué vas a hacer con la tabla ITEM (que podría ser cualquier cosa).

Piensa el los datos necesarios a almacenar, los procesos a implementar y te irán apareciendo CAMPOS y RELACIONES.

Snayder187 10-04-2017 19:04:33

Esta es mi base de datos ya terminada...

Código SQL [-]
CREATE DATABASE EVENTOS
GO

USE EVENTOS
GO


create TABLE CATEGORIA
(
  idcategoria int identity(1,1) primary key,
  nom_categoria varchar(100) not null
)

create TABLE TIPO_ITEM
(
  idtipoitem int identity(1,1) primary key,
  idcategoria int foreign key references CATEGORIA(idcategoria),
  nom_tipoitem varchar(100) not null
)

create TABLE ITEM
(
  iditem int identity(1,1) primary key,
  idtipoitem int foreign key references TIPO_ITEM(idtipoitem),
  des_item varchar(100) not null,    
  con_item varchar(20) not null,    
  sto_item int not null        
)

create TABLE DETALLE_ITEM
(
  iddetalleitem int identity(1,1) primary key,
  idtipoitem int foreign key references TIPO_ITEM(idtipoitem),
  med_detalleitem varchar(50) not null,    
  cap_detalleitem int not null,        
  dir_detalleitem varchar(100) not null
)

create TABLE PROVEEDOR
(
  idproveedor int identity(1,1) primary key,
  ruc_proveedor char(11) not null,
  rzo_proveedor varchar(100) not null,
  con_proovedor varchar(100) not null,
  cel_proovedor varchar(12) not null,
  dir_proovedor varchar(100) not null,
  tel_proovedor varchar(11) null,
  ema_proovedor varchar(80) null,
  est_proovedor varchar(1) not null
)

create TABLE PERSONAL
(
  idpersonal int identity(1,1) primary key,
  nom_personal varchar(80) not null,
  ape_personal varchar(100) not null,
  dni_personal varchar(8) not null,
  fna_personal date not null,
  dir_personal varchar(100) not null,
  tel_personal varchar(11) null,
  cel_personal varchar(13) not null,
  esc_personal varchar(25) not null,
  ema_personal varchar(100) not null,
  car_personal varchar(30) not null,
  est_personal varchar(1) not null
)

create TABLE PRECIOS
(
  idprecio int identity(1,1) primary key,
  iditem int foreign key references ITEM(iditem),
  idproveedor int foreign key references PROVEEDOR(idproveedor),
  fec_precios date not null,
  pco_precios double(6,2) not null,    
  pve_precios double(6,2) not null,    
  uti_precios double(6,2) not null     
)

create TABLE COTIZACION
(
  idcotizacion int identity(1,1) primary key,
  sol_cotizacion varchar(150) not null,
  tel_cotizacion varchar(13) not null,
  des_cotizacion varchar(100) not null,
  inv_cotizacion varchar(8) not null,
  fec_cotizacion date not null,
  idproveedor int foreign key references PROVEEDOR(idproveedor)
)

create TABLE EVENTO
(
  idevento int identity(1,1) primary key,
  idcotizacion int foreign key references COTIZACION(idcotizacion),
  hin_evento date not null,      
  hfi_evento date not null,      
  est_evento varchar(15) not null,
  dir_evento varchar(150) not null,
  idpersonal int foreign key references PERSONAL(idpersonal),
  tev_evento varchar(70) not null,    
  fec_evento date not null
)

create TABLE MENAJE
(
idmaneja int identity(1,1) primary key,
idcotizacion int foreign key references COTIZACION(idcotizacion),
iditem int foreign key references ITEM(iditem)
)

create TABLE CLIENTE
(
  idcliente int identity(1,1) primary key,
  tip_cliente char(1) not null,      
  tdo_cliente varchar(20) not null,    
  ndo_cliente varchar(11) not null,    
  nom_cliente varchar(150) not null,
  dir_cliente varchar(150) not null,    
  tel_cliente varchar(13) not null,    
  ema_cliente varchar(100) null      
)
  
create TABLE CONTRATO
(
  idcontrato int identity(1,1) primary key,
  idcliente int foreign key references CLIENTE(idcliente),
  fec_contrato date not null,
  est_contrato varchar(50) not null,    
  idevento int foreign key references EVENTO(idevento),
  cuo_contrato int not null,    
  imp_contrato double not null,      
  ima_contrato image not null      
)

create TABLE COMPRA
(
  idcompra int identity(1,1) primary key,
  idproovedor int foreign key references PROVEEDOR(idproveedor),
  iditem int foreign key references ITEM(iditem),
  ser_compra varchar(6) not null,    
  nco_compra varchar(8) not null
)  

create TABLE ALQUILER
(
idalquiler int identity(1,1) primary key,
idproovedor int foreign key references PROVEEDOR(idproveedor),
iditem int foreign key references ITEM(iditem),
idcontrato int foreign key references CONTRATO(idcontrato)
)


La franja horaria es GMT +2. Ahora son las 11:16:12.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi