Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Help needed with implementing an ER diagram!

Author  Topic 

nonwitty
Starting Member

1 Post

Posted - 2011-05-28 : 20:39:02
I'm currently doing an assignment for my course in database design and was looking for some advice on assigning keys in PSQL. I'm looking to create a form which will fetch travel, train and driver information from the databse. Here is the initial ER design: [url]http://dl.dropbox.com/u/23601298/IBIS-ERD.pdf[/url]

It's a design for a small railways company's database. I'm not entirely sure how I should deal with the "Trains" table. I was thinking about creating an Train ID column for the primary key to link to the "Carriage" table. I know this would essentially "lock" the carriages to a certain train but this is a very simplified exercise to begin with. I'm also uncertain how to implement the "seating_capacity"/"standing_capacity" columns since they have to be calculated from the other table.

Another problem is the "Driver" table. The driver has to be assigned to a train but they can drive many different trains, services and runs during the day. Should I create the foreign key to the "Run" table instead?



I'm sorry if this is a bit long winded but I'm getting very frustrated with this . Thank you for helping.


These are the Assumptions:

Each whole route is served by only one service(though a route may be wholly contained within another).

For the purposes of simplicity, there are no differences in service for weekdays, weekends and holidays. You may choose to extend or change this

There are no inconsistencies or break during the timetable days – the services are entirely regular. You may choose to extend or change this

A route is made up of a number of stops, in a particular sequence.

Trains are either enhanced for use by those with disabilities or not – there are no degrees of enhancement

A train is defined as a single engine pulling a specified number of carriages

A run is a single, specific instance of a service running along a route

Each driver may be able to drive multiple runs and services in a day, and may drive multiple trains to do so.

Each train is assigned a single driver

denis_the_thief
Aged Yak Warrior

596 Posts

Posted - 2011-05-30 : 09:49:48
For the Train/Carriage issue, you probably want a table like:
Journey
--------
JourneyID
TrainID
CarriageID
ScheduleTime
...

I personally find Database Diagrams more helpful than ER Diagrams.
Go to Top of Page

denis_the_thief
Aged Yak Warrior

596 Posts

Posted - 2011-05-30 : 09:58:36
quote:
Originally posted by denis_the_thief

For the Train/Carriage issue, you probably want a table like:
Journey
--------
JourneyID
TrainID
CarriageID
ScheduleTime
...

I personally find Database Diagrams more helpful than ER Diagrams.



No, that's not right. How about:

Journies
--------
JourneyID
RouteID
ScheduledTime
ActualTime

JourneyTrains
-------------
JourneyID
TrainID

JourneyCarriages
----------------
JourneyID
CarriageID
Go to Top of Page

denis_the_thief
Aged Yak Warrior

596 Posts

Posted - 2011-05-30 : 10:06:48
quote:
Originally posted by denis_the_thief

quote:
Originally posted by denis_the_thief

For the Train/Carriage issue, you probably want a table like:
Journey
--------
JourneyID
TrainID
CarriageID
ScheduleTime
...

I personally find Database Diagrams more helpful than ER Diagrams.



No, that's not right. How about:

Runs
--------
RunID
RouteID
ScheduledTime
ActualTime

RunTrains
-------------
RunID
TrainID

RunCarriages
----------------
RunID
CarriageID


Go to Top of Page
   

- Advertisement -