OT: SQL Null fields

OT: SQL Null fields

Postby Marc Vanzegbroeck » Sat Aug 25, 2012 5:26 pm

Hi,

I know it's not really a harbour/Fivewin question but now I have table with appointment-data with a couple of fields.
Some appointments need extra info (50 fields extra).
Only about 5% need this extra info. To save disc-space I have created a second table with those fields and one with the appointment-id, to link with the main table.

Now I'am converting this to MySQL and I was wondering if this is still necessary.
If I only create one table with all the info. Are the empty fields (null) still consuming space on the hard-disk in MySQL?

I know that a DBF-file use the same disk-space for an empty field as one with data, but does MySQL do this also?

Thanks,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: OT: SQL Null fields

Postby Kleyber » Sat Aug 25, 2012 5:41 pm

Marc,

In MySQL you can use the VARCHAR type, in order to consume less space in the database, once this type of field increases only when receive data. If you use CHAR type the space you have defined in the field remains the same all the time. In this case I suggest you to use a second table, as you said and there is no problem (my opinion).
Kleyber Derick

FWH / xHb / xDevStudio / SQLLIB
User avatar
Kleyber
 
Posts: 581
Joined: Tue Oct 11, 2005 11:28 am
Location: São Luiz, Brasil

Re: OT: SQL Null fields

Postby Adolfo » Sat Aug 25, 2012 5:47 pm

Marc.

Using TEXT fields could be a solution. You'll know that each field will use at least 10 BYTES, but you can put whatever you can within these fields.
You can try first with TINYTEXT, (up to 255 char length max) or TEXT ( here you have 2^24 characters)

Remember that using TEXT columns, (if you modify them constantly) you can produce table fragmentation, whic can be overcome with an OPTIMIZE TABLE command once in a while.

From Chile
Adolfo
;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
User avatar
Adolfo
 
Posts: 860
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile

Re: OT: SQL Null fields

Postby Marc Vanzegbroeck » Sat Aug 25, 2012 6:49 pm

Kleyber, Adolfo,

Thank you for the information.
Most of the fields are CHAR. So I think I will continue to use my second table.
It's less work to convert my program :D , but I was just wondering how MySQL use his space, so I could maybe use in the future only one instead 2 tables if have the same situation...

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 101 guests