Shine
Shine

Reputation: 197

Database design of Railway reservation system

I am designing Railway reservation system. I am having below tables.

StationTable(Contails all the stations to which i can provide the railway service.)
<StationID>->PrimaryKey
<StationName>

TrainTable
<TrainNumber>-> PrimaryKey
<TrainName>
<SourceStationID>->FK StationTable(<StationID>)
<DestinationStationID>->FK StationTable(<StationID>)

Passenger is identified by TicketID

   PassengerTable
    <TicketID>->Primary key
    <PassengerID>
    <PassengerName>
    <Age>
    <Sex>
    <Status>

As one passenger can book ticket for many trains. Their is many to many relation between TicketID and TrainID.

PassengerTrainTable -> FK PassengerTable() -> FK TrainTable()

I am unable to relate to No of seats in a train and the status. How can i relate those in relation with current table or how can i go with new tables.

Upvotes: 0

Views: 11814

Answers (1)

Yurii Hohan
Yurii Hohan

Reputation: 4171

Many-to-many relationships are solved with the help of an extra table. In this case the ticket sale table is natural to your domain. Seethe sample here

Upvotes: 2

Related Questions