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 |
+----+----------+-----------+--------------+--------+