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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:22:54+00:00 2026-06-10T07:22:54+00:00

I am developing an application management business (sales, suppliers, customers, products, …) for a

  • 0

I am developing an application management business (sales, suppliers, customers, products, …) for a new company. To begin, I need to create a database. Could you please tell me if the BD scheme bellow is good and optimized ?

CREATE TABLE IF NOT EXISTS `company` (
  id UNSIGNED INT NOT NULL auto_increment,
  `SIRET` varchar(50) NOT NULL,
  `nom` varchar(50) NOT NULL,
  `description` varchar(500) NOT NULL,
  `enable` ENUM('YES', 'NO') DEFAULT 'YES',
  `level` int(1) NOT NULL,
  PRIMARY KEY  (id),
  UNIQUE KEY SIRET (SIRET)
) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

// contactType can be one of the 3 values : email, phone, fax
CREATE TABLE IF NOT EXISTS `contactType` (
  id UNSIGNED INT NOT NULL auto_increment,
  `contactType` ENUM('email', 'phonenumber', 'faxnumber')
  `mobile` ENUM('YES', 'NO') default 'NO',
  PRIMARY KEY  (id),
  UNIQUE KEY type (contactType)
) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `contacts` (
  id UNSIGNED INT NOT NULL auto_increment,
  `SIRET` varchar(50) NOT NULL,
  `contactType` varchar(50) NOT NULL, // A reference to contactType just above
  `contactref` varchar(50) NOT NULL, // Phone number, fax number or email adress
  PRIMARY KEY  (id),
  UNIQUE KEY type (SIRET)
) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `customers` (
  id UNSIGNED INT NOT NULL auto_increment,
  `SIRET` varchar(50) NOT NULL,
  PRIMARY KEY  (id),
  UNIQUE KEY type (SIRET)
) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `supplier` (
  id UNSIGNED INT NOT NULL auto_increment,
  `SIRET` varchar(50) NOT NULL,
  PRIMARY KEY  (id),
  UNIQUE KEY type (SIRET)
) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `industry` (
  id UNSIGNED INT NOT NULL auto_increment,
  `industry` varchar(250) NOT NULL,
  PRIMARY KEY  (id),
  UNIQUE KEY type (activite)
) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `entreprisePerIndustry` (
  id UNSIGNED INT NOT NULL auto_increment,
  `industry_id` varchar(250) NOT NULL, // Chemical, Computer, Consulting, ...
  FOREIGN KEY (industry_id) REFERENCES industry(id) ON DELETE CASCADE,
  `SIRET` varchar(50) NOT NULL,
  PRIMARY KEY  (id),
  UNIQUE KEY type (industry_id)
) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
  • 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-06-10T07:22:55+00:00Added an answer on June 10, 2026 at 7:22 am

    Below are few TIPS which can helps you to create better DB

    • Change table engine from MyISAM to InnoDB if you want make foreign key constrains to work.
    • AUTO INCREMENT DataType should be UNSIGNED INT. this will double the range.

      `id` INT UNSIGNED NOT NULL AUTO_INCREMENT`
      
    • if a column value chosen from a list of permitted values then change dataType to ENUM .In your case enable, level can be turned into ENUM dataType

      `enable` ENUM( 'y', 'n' ) NOT NULL DEFAULT 'y' COMMENT 'y:yes; n:no' `
      
    • add foreign key relation to

      contacts.contactType with contactType.id

      entreprisePerIndustry .industry with industry.id

    update

    I have created basic and optimized table structure ( AFAIK ).

    --
    -- Table structure for table `tbl_company`
    --
    CREATE TABLE IF NOT EXISTS `tbl_company` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `siret` varchar(50) NOT NULL,
      `nom` int(11) NOT NULL,
      `description` varchar(250) NOT NULL,
      `enable` enum('y','n') NOT NULL DEFAULT 'y' COMMENT 'y:yes; n:no',
      `level` enum('1','2') NOT NULL DEFAULT '1',
      `last_updated_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
    
    --
    -- Table structure for table `tbl_contact`
    --
    
    CREATE TABLE IF NOT EXISTS `tbl_contact` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `siret` varchar(50) NOT NULL,
      `contact_type` enum('email','phone','fax') NOT NULL DEFAULT 'email',
      `contact_ref` varchar(100) NOT NULL COMMENT 'Phone number, fax number or email adress',
      `last_updated_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
      PRIMARY KEY (`id`),
      UNIQUE KEY `siret` (`siret`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
    
    ...
    ...
    

    complate structure is here

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

Sidebar

Related Questions

I am developing one application in J2me MIDP 1.0 It requires local database management.
My company is currently developing a project management web application in PHP, and I
I am developing a PHP application that uses SQLite as database management system, MySQL
I am developing a application for Sales Order Management using ASP.NET MVC 3.0. I
I am developing a desktop application for pdf file management using C#. When I
Context: Hello, I'm developing an on line application of Tennis Club Management... I would
I am developing a project management application for in-house use. For storing project requirements,
I am developing a Delphi documents management application, so somehow I am giving the
I am developing an application, whose data management is realized through Core Data, and
Which use of connection management is better while developing a windows based application which

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.