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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:50:22+00:00 2026-06-12T16:50:22+00:00

Is it ok to use ‘NULL’ value in the deal.tariff_id to represent that it

  • 0

Is it ok to use ‘NULL’ value in the deal.tariff_id to represent that it belong to any tariffs in the tariff_data table with affiliate_id=3?

For example:

mysql> select * from phone;
+----+------------------+
| id | name             |
+----+------------------+
|  4 | HTC Sensation XL |
| 26 | iPhone 4s        |
| 25 | iPhone 5         |
| 24 | Nokia C3-01      |
+----+------------------+

mysql> select * from tariff;
+----+-----------------+-----------------+--------------+-------------+
| id | name            | tariff_duration | monthly_cost | description |
+----+-----------------+-----------------+--------------+-------------+
|  1 | Business Plan 1 |              24 |         5.00 |             |
|  2 | Business Plan 2 |              24 |        10.00 |             |
|  4 | Business Plan 3 |              24 |        15.52 |             |
|  5 | Business Plan 4 |              24 |        18.52 |             |
|  8 | Super Plan      |              12 |        15.00 |             |
+----+-----------------+-----------------+--------------+-------------+

mysql> select * from tariff_data;
+----+-----------+--------------+-------+
| id | tariff_id | affiliate_id | bonus |
+----+-----------+--------------+-------+
|  1 |         1 |            3 | 34.00 |
|  2 |         2 |            3 | 44.00 |
|  5 |         3 |            3 | 10.00 |
|  6 |         4 |            3 | 10.00 |
|  7 |         5 |            3 | 10.00 |
+----+-----------+--------------+-------+

On a deal table, you can see affiliate_id=3 and tariff_id=NULL is belong to any tariff that are listed in tariff_data table. I did this to reduce amounts of rows in the deal. If I don’t include NULL that mean I have to include many tariff_id with same phone_id and vice versa.

mysql> select * from deal;
+----+----------+-----------+--------------+--------+
| id | phone_id | tariff_id | affiliate_id | active |
+----+----------+-----------+--------------+--------+
|  1 |        4 |      NULL |            3 |      1 |
|  3 |       24 |      NULL |            3 |      1 |
|  9 |       24 |         8 |            4 |      1 |
| 10 |       25 |         8 |            4 |      1 |
| 11 |       26 |         8 |            4 |      1 |
+----+----------+-----------+--------------+--------+

Update, example if I did not use NULL value:

mysql> select * from deal;
+----+----------+-----------+--------------+--------+
| id | phone_id | tariff_id | affiliate_id | active |
+----+----------+-----------+--------------+--------+
|  1 |        4 |         1 |            3 |      1 |
|  2 |        4 |         2 |            3 |      1 |
|  3 |       24 |         1 |            3 |      1 |
|  4 |       24 |         2 |            3 |      1 |
|  5 |       24 |         3 |            3 |      1 |
|  6 |       24 |         4 |            3 |      1 |
|  7 |       24 |         5 |            3 |      1 |
|  9 |       24 |         8 |            4 |      1 |
| 10 |       25 |         8 |            4 |      1 |
| 11 |       26 |         8 |            4 |      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-12T16:50:23+00:00Added an answer on June 12, 2026 at 4:50 pm

    As the other two answers, this is not a good idea. Here’s a suggestion for normalization.

    You want some of the deals to represent a “general” deal, irregardless of tariff. You can split the deail table into two, one for simple deals and one for the general ones:

    mysql> select * from deal_simple;
    +----+----------+-----------+--------------+--------+
    | id | phone_id | tariff_id | affiliate_id | active |
    +----+----------+-----------+--------------+--------+
    |    |       24 |         8 |            4 |      1 |
    |    |       25 |         8 |            4 |      1 |
    |    |       26 |         8 |            4 |      1 |
    +----+----------+-----------+--------------+--------+
    
    mysql> select * from deal_general_tariff;
    +----+----------+--------------+--------+
    | id | phone_id | affiliate_id | active |
    +----+----------+--------------+--------+
    |    |        4 |            3 |      1 |
    |    |       24 |            3 |      1 |
    +----+----------+--------------+--------+
    

    You could then have the expanded results with the simple query (I assume you did not include by mistake 3 more rows that relate phone_id 4 with tariff_id 3, 4, 5):

    SELECT phone_id, tariff_id, affiliate_id, active
    FROM deal_simple
    
    UNION
    
    SELECT dgt.phone_id, td.tariff_id, dgt.affiliate_id, dgt.active
    FROM 
        deal_general_tariff AS dgt
      JOIN 
        tariff_data AS td
          ON td.affiliate_id = dgt.affiliate_id ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Use AES/Rijndael or any symmetric encryption. Encrypt the hidden value using itself as the
use Text::Table; my $tb = Text::Table->new(Planet,Radius\nkm,Density\ng/cm^3); $tb->load( [ Mercury,2360,3.7], [ Mercury,2360,3.7], [ Mercury,2360,3.7], );
use Modern::Perl; use Algorithm::Permute; use List::AllUtils qw/uniq/; find_perms(1151); sub find_perms { my ($value) =
use strict; my $var = NULL; will raise an error of Bareword NULL not
use javascript or other method ? have any recommendation?
use strict; use Time::HiRes qw[gettimeofday tv_interval]; my $start_index = int(rand(50))+100;#this value is arbitrary for
Use scenario is pretty simple: I have a desktop only application that could be
Use case: I find a piece of code that I do not understand at
use case example I have a servlet that is receiving login requests. If a
Use default: <input type=radio name=restype value=resdef onfocus=document.getElementById('resupload').disabled = true; document.getElementById('resadres').disabled = true; checked=checked /><br

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.