铁路预订系统数据库设计

时间:2011-10-07 06:19:33

标签: database-design

我正在设计铁路预订系统。 我在桌子下面。

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>)

乘客由TicketID识别

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

因为一名乘客可以为许多火车预订机票。它们是TicketID和TrainID之间的多对多关系。

PassengerTrainTable - &GT; FK PassengerTable() - &GT; FK TrainTable()

我无法联系到列车中的座位和状态。 我如何将与当前表格相关的内容联系起来,或者我如何使用新表格。

1 个答案:

答案 0 :(得分:2)

在额外的表格的帮助下解决了多对多关系。在这种情况下,售票表对您的域名来说很自然。见the sample here

相关问题