what is MySql signed / unsigned option?

images

When to use signed / unsigned option in MySql.

Mysql Says: 

All integer types can have an optional (nonstandard) attribute UNSIGNED. Unsigned type can be used to permit only nonnegative numbers in a column or when you need a larger upper numeric range for the column. For example, if an INT column is UNSIGNED, the size of the column’s range is the same but its endpoints shift from -2147483648 and 2147483647 up to 0 and 4294967295.

When to use UNSIGNED data type?

If your field will never stores negative values, then its best to use UNSIGNED, that will give you faster index and more range.

When to use  SIGNED data type?

If you need to store negative then use signed, but remember your number range is half now.

 

Note: Common mistake people do is to store primary number ( auto -increment ) as as signed. Which mean you are already reducing your number range even you will never use negative number as your primary key.

MySQL supports the SQL standard integer types INTEGER (or INT) and SMALLINT. As an extension to the standard, MySQL also supports the integer typesTINYINT, MEDIUMINT, and BIGINT. The following table shows the required storage and range for each integer type.

Type Storage Minimum Value Maximum Value
(Bytes) (Signed/Unsigned) (Signed/Unsigned)
TINYINT 1 -128 127
0 255
SMALLINT 2 -32768 32767
0 65535
MEDIUMINT 3 -8388608 8388607
0 16777215
INT 4 -2147483648 2147483647
0 4294967295
BIGINT 8 -9223372036854775808 9223372036854775807
0 18446744073709551615

How to create own domain based nameservers / vanity nameservers / child nameservers?

Creating your own domain based vanity nameserver:

Different domain registers call own domain based nameservers by different terms. Godaddy calls it vanity nameservers, resellerclub calls it child nameserver, some calls it branded nameserver and so on.

What is vanity nameservers?

Well, if you own a domain name you like to have your own branded nameserver like ns1.example.com and ns2.example.com. This is purely done for branding purpose and if you can manage the dns in your hosting server so that you can have more flexibility.

 

How to setup vanity nameservers?

Find out your domain ip address, you can do that by doing ping. for this example we will use 192.168.0.1 and you need at least two nameservers to your website, so its better if you have two ips but one IP will also work and enough as many of us only have one server for our website.

So, lets create two name servers as follows:
ns1.example.com  192.168.0.1
ns2.example.com 192.168.0.1

In above example, example.com is domain name so replace it with your domain name , and ns1 and ns2 are the nameserver we are creating, and 192.168.0.1 is the ip address of our domain name provided by hosting company.

Normally, ns1 is pretty standard nameserver naming convention but you can change it as you like. So in general, for linux based server, ns1, ns2 is used while for window based server nt1, nt2 is used. But these are just  naming convention you can use anything you like.

 

Domain side:

Step 1: Add Glue record:
First we need to setup in domain side. So go to the domain registrar, where domain is register.  And add a glue record for your domain.

glue records are A records in DNS. Different domain registrar used different names, some call it host names, some call it child name server. But its just a A record in your DNS.

So look for DNS settings / find child name server / host name in your domain register to add this record i11n your domain control panel of domain you like to add name server.

Format of glue record is this:

For ns1.example.com
record name: ns1
 Ip address: 192.168.0.1
 record type: A
for ns2.example.com
record name: ns2
 Ip address: 192.168.0.1
 Record Type: A

Note:
Some domain register, you give full name server not just ns1 and ns2, so look in their help section for details.

 

Step 2: Point your name server in your domain.
Go to change name server section for your domain so that you can now point your domain nameserver to nameserver you just set.
details are :

nameservers:
 ns1.example.com
 ns2.example.com

for example in go daddy click on edit nameserver next to domain and put your nameservers there.

 

Server side:

Now in server, where you have hosted your domain, we need to setup DNS so that server will know, which nameserver that website is authorized to.

So we need to add A record, and NS records there so go to DNSsection in your website hosting control panel and add following records:

add A record:

 ns1     A   192.168.0.1
ns2  A 192.168.0.1

 

A is record type.

 

Add NS Record:

ns1.example.com.   NS
ns2.example.com.  NS

 

NS is record type, and dont forget tailing dot in your nameserver name.  don’t forget to restart your nameserver.

 

And you are done. !