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

  • SEARCH
  • Home
  • 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 4266874
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:49:14+00:00 2026-05-21T06:49:14+00:00

So I am working on a fairly small script for the company I work

  • 0

So I am working on a fairly small script for the company I work at the help us manage our servers better. I don’t use MySQL too often though so I am a bit confused on what would be the best path to take.

I am doing something like this…

$sql = "CREATE TABLE IF NOT EXISTS Servers
    (
        MachineID int NOT NULL AUTO_INCREMENT,
        PRIMARY KEY(MachineID),
        FirstName varchar(32),
        LastName varchar(32),
        Datacenter TINYINT(1),
        OperatingSystem TINYINT(1),
        HostType TINYINT(1)
    )";

$result = mysql_query($sql,$conn);
check ($result);

$sql = "CREATE TABLE IF NOT EXISTS Datacenter
    (
        DatacenterID int NOT NULL AUTO_INCREMENT,
        PRIMARY KEY(DatacenterID),
        Name varchar(32),
        Location varchar(32)
    )";

$result = mysql_query($sql,$conn);
check ($result);

Basically inside the Servers table, I will be storing the index of an entry in another table. My concern is that if we remove one of those entries, it will screw up the auto incremented indexes and potentially cause a lot of incorrect data.

To explain better, lets say the first server I add, the Datacenter value is 3 (which is the DatacenterID), and we remove the id 1 (DatacenterID) Datacenter at a later time.

Is there a good way to do this?

  • 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-21T06:49:15+00:00Added an answer on May 21, 2026 at 6:49 am

    Auto increment only has an effect on inserting new rows into a table. So you insert three records into database and they get assigned ids of 1, 2, and 3. Later you delete id 1, but the records at id 2 and 3 are unchanged. This says nothing of any of the server records that might be trying to reference the database id 1 record though that is now missing.

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

Sidebar

Related Questions

I've been working writing fairly small applications and doing some maintenance work for some
Hi We're a small web development company with 3 Lunarpages dedicated Plesk/Apache/MySQL/CentOS servers hosting
I'm working on a fairly large project for a trading company in Philadelphia. The
I am working on a small bit of script that will allow for easy
Our project is working within fairly close quarters code-wise (a lot of changes happening
I'm working with a small team, and we're fairly evenly split between the following
I hope you can help me. I am working on a small Sinatra Rails
Background I recently joined a small start-up after working at a large company. I'm
My experience with databases is with fairly small web applications, but now I'm working
I have a menu working fairly well but can't figure out how to make

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.