PostgreSQL - Ejercicio

 
Vista:
sin imagen de perfil

Ejercicio

Publicado por Cecilia (1 intervención) el 23/04/2024 13:54:36
Mis respetos a todos. Adjunto el enunciado, las tablas, código de creación de las tablas y el código que escribí. No arroja error al ejecutar, solo que no pude resolver la parte del enunciado de cantidad de horas previstas de vuelo para cada uno. Mis conocimientos son básicos por eso pido la ayuda de ustedes por favor. Atentamente


/* Desplegar la lista de Pasajeros de los Viajes previstos para el día de hoy,
mostrando todos sus datos del Pasajero, el Pasaje,
la descripción de la Clase, y la cantidad de horas previstas de vuelo para cada uno .*/


Pasajero ero
Columna Tipo Dato Constraint
NroPasajero int PK,SA
Nombre varchar(30) NN
Apellido varchar(30) NN
Domicilio varchar(50) NN
DireccionLaboral varchar(50)
TelefonoParticular varchar(15)
TelefonoLaboral varchar(15)
NroPasaporte varchar(15) NN ViajeRutaAerea
FechaNacimiento datetime NN
CodPais smallint FK,NN
Observacion varchar(255) NN


Pasaje
Columna Tipo Dato Constraint
NroPasaje int PK,SA
NroPasajero int FK,NN
FechaEmision datetime NN
CodClase smallint FK,NN
NroAsiento smallint NN
PrecioPasaje money NN
NroViaje int FK,NN


Viaje
Columna Tipo Dato Constraint
NroViaje int PK,SA
NroAvion int FK,NN
FecHorSalida datetime NN
FecHorLlegadaPrevista datetime NN PasajeRutaAerea
FecHorLlegadaReal datetime


Clase
Columna Tipo Dato Constraint
CodClase smallint PK
Descripcion varchar(40) NN, ND









1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
CREATE TABLE Pasajero
(NroPasajero int  GENERATED ALWAYS AS IDENTITY, PRIMARY KEY(NroPasajero),
Nombre varchar(30) NOT NULL,
Apellido varchar(30) NOT NULL,
Domicilio varchar(50) NOT NULL,
DireccionLaboral varchar(50),
TelefonoParticular varchar(15),
NroPasaporte varchar(15) NOT NULL,
FechaNacimiento date NOT NULL,
CodPais smallint NOT NULL,
Observacion varchar(255) NOT NULL,
CONSTRAINT FK_Pasajero FOREIGN KEY(CodPais) REFERENCES Pais(CodPais))
 
 
 
CREATE TABLE Pasaje
(NroPasaje int GENERATED ALWAYS  AS IDENTITY,  PRIMARY KEY (NroPasaje),
NroPasajero int NOT NULL,
FechaEmision date NOT NULL,
CodClase smallint NOT NULL,
NroAsiento smallint NOT NULL,
PrecioPasaje money NOT NULL,
NroViaje int Not Null,
Constraint FK_Pasaje_Pasajero Foreign key (NroPasajero) REFERENCES Pasajero(NroPasajero),
Constraint FK_Pasaje_Clase Foreign Key (CodClase) REFERENCES Clase(CodClase),
Constraint FK_Pasaje_Viaje Foreign Key(NroViaje) REFERENCES Viaje(NroViaje))
 
 
 
 
 
CREATE TABLE Viaje
(NroViaje int GENERATED ALWAYS AS identity, PRIMARY KEY (NroViaje) ,
NroAvion int NOT NULL,
FecHorSalida date Not null,
FecHorLlegadaPrevista date Not Null,
FecHorLlegadaReal date,
Constraint FK_Viaje_Avion Foreign Key (NroAvion) REFERENCES Avion(NroAvion))
 
 
 
CREATE TABLE Clase
(CodClase smallint PRIMARY KEY,
Descripcion varchar(40) NOT NULL UNIQUE)
 
 
 
 
select P.,Pa.,C.Descripcion from Pasajero P  inner join Pasaje PA
                               on P.NroPasajero = PA.NroPasajero
							     inner Join Viaje V
							   on PA.NroViaje = V.Nroviaje
							      inner Join Clase C
								  on PA.CodClase = C.CodClase
							   where V.FecHoraSalida=current_date
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder