Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 819021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:14:28+00:00 2026-05-15T02:14:28+00:00

I have limited SQL background, basically a small amount of manipulation through HTML and

  • 0

I have limited SQL background, basically a small amount of manipulation through HTML and mostly with pre-existing databases. What I am trying to do is set up a database that will store time information for bus routes. So basically I have different routes with stops for each route and then a list of times that the bus arrives at each stop. Here is an example of a table of times from their website: Link.

I am wondering what would be the best way to layout my database/tables?

Also what is the purpose of the _id field in each table?

Thanks,
Rob!

P.S. Sorry if my lack of knowledge on the subject has caused me to post a duplicate question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:14:29+00:00Added an answer on May 15, 2026 at 2:14 am

    You asked two questions:

    1. The ‘id’ field is a good convention as a unique row identification. It is not strictly required, and some data that has its own unique serial number for each row will use that serial number instead. Programs often want to look up the entire record by the unique row identification so the field should be a primary key. The commonly used clause for creating the id is “id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id)”. A unique id will be assigned automatically whenever you add a new record. See Tizag’s MySQL Tutorial for a verbose breakdown. Personally, some name these “_id”, e.g., “route_id”, “bus_id”, and your style may vary.

    2. Laying out your data depends a bit on what you want to do with it. My guess is that for each bus route, you want to find the next bus at a particular stop after some time and then when that bus arrives at some next stop. Each route has many stops; a stop might be shared among routes; a route varies during the day by skipping some stops; routes go in two directions; etc. I would add the abstraction of a ‘run’ which one bus run through the stops from start to finish.

    My first guess at laying it out would be:

    A bus route has a bus name, number, and other info: “#1 Red”, “South And West”, “SF Muni”, “map://…”

    A stop has a unique name and other info: “North Grand Mall”. “South”, “Under the cherry, west of grand avenue.”

    A run has a route number, days of the week, a direction, maybe a sequence number of the run in that direction that day, maybe a start/stop time for the run: “63 (route_id for #1 Red)”, “reverse direction”, “MTWRF” (weekdays), “2” (2nd run), “7:00”, “7:36”.

    Then you have a schedule table of “Run_id”, “Stop_id”, “Stop Sequence Number”, “Time”.

    Write out your planned schema, and then start trying to write schemas against them. Don’t be surprised by a couple multiple joins “SELECT * from Schedule as S, Run as R, Bus as B for B … WHERE B.id == R.bus_id and S.run_id == R.id and B.id = (requested bus) and S.time >= now() and ….” You denormalize for performance after it works.

    That’s all my free advice. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 457k
  • Answers 457k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Select the function's code and then a new option will… May 15, 2026 at 10:57 pm
  • Editorial Team
    Editorial Team added an answer A cut of a connected graph is a minimal set… May 15, 2026 at 10:57 pm
  • Editorial Team
    Editorial Team added an answer You could use the mod_expires module of Apache2 to set… May 15, 2026 at 10:57 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.