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 3673120
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:41:36+00:00 2026-05-19T02:41:36+00:00

I’m very confused in creating Tables in MySQL because I read some PHP tutorials

  • 0

I’m very confused in creating Tables in MySQL because I read some PHP tutorials and the authors create two tables in their database and then linking them up later in PHP using joins.

Here’s an example I got from an article..

Here the author created the table users and groups.

    CREATE TABLE users (
       id int(8) NOT NULL auto_increment,
       name varchar(255) NOT NULL default '',
       pass varchar(255) NOT NULL default '',
       PRIMARY KEY (id)
    ) TYPE=InnoDB;

   CREATE TABLE groups (
       uid int(8) NOT NULL default '0',
       grp varchar(255) NOT NULL default ''
   ) TYPE=InnoDB;

When I look at it, isn’t the groups table not necessary? I mean I can just create the table this way:

CREATE TABLE users (
       id int(8) NOT NULL auto_increment,
       name varchar(255) NOT NULL default '',
       pass varchar(255) NOT NULL default '',
       grp varchar(255) NOT NULL default ''
       PRIMARY KEY (id)
    ) TYPE=InnoDB;

In this way, I can just query the database and I don’t need to join the two tables together at all.

So what’s the purpose of creating two tables and not one? Please explain to me why linking together two tables is better than one.

  • 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-19T02:41:37+00:00Added an answer on May 19, 2026 at 2:41 am

    I a lot of authentication systems 1 user can have multiple groups. Therefore 2 tables are necessary. If you want to have a good idea how to design your tables than you can have a read on database normalization.

    even beter would be if you create a table for groups, a table for users, and a table for users in groups. This is because it’s common to have multiple users in a group and users can have multiple groups (many to many relation). Many to many relations in relational databases are not possible. Therefor you need the extra table.
    An other advantage of this system is that if you decide to change the group name than you don’t need to change that name for each user. You can just change the name once and it’s changed for all users.

    You get something like this.

    - table user
      - id
      - username
      - password
      - etc
    
    - table groups
      - id
      - name
      - etc
    
    - table usergroups
      - userid
      - groupid
    

    You can also have a look at FCO-IM which is a more complicated method to design databases compared to ERM, but might be handy for bigger and more complicated databases.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I have a bunch of posts stored in text files formatted in yaml/textile (from
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker

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.