vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Database Design (https://vborg.vbsupport.ru/showthread.php?t=168638)

IrPr 01-24-2008 11:54 AM

Database Design
 
As im not such expert as well as you guys are, I've to ask some basic database designin quetions
I've to design a database for artists details, such as Biography
but just 10% of all my records have Biography data on that
there are 2 methods to me for design this table and its scripts:
  1. create one table to keep all fields on that, NULL MEDIUMTEXT field for biography
    in this case my table will store one field that just used for 10% of records
  2. create 2 tables and use one to one relationship between artists and biography
    in this case ive to use more query or use JOIN for my code
Which one is more optimized?

Another question:
I've to store two links for my tracks, low quality and high quality
Which one is more optimized?
to use one field in tracks table and use a splitter for the urls or just using serialized data
or use another table to join and use keys property?

Thanks

Eikinskjaldi 01-24-2008 08:43 PM

Quote:

Originally Posted by IrPr (Post 1427943)
As im not such expert as well as you guys are, I've to ask some basic database designin quetions
I've to design a database for artists details, such as Biography
but just 10% of all my records have Biography data on that
there are 2 methods to me for design this table and its scripts:

[create one table to keep all fields on that, NULL MEDIUMTEXT field for biography
in this case my table will store one field that just used for 10% of records

this is the correct method. Having sparse data in the system is not a problem.

Quote:

Another question:
I've to store two links for my tracks, low quality and high quality
Which one is more optimized?
to use one field in tracks table and use a splitter for the urls or just using serialized data
or use another table to join and use keys property?
Serialisation is always a last resort. Either do it programmatically or have two fields, one for each type.

IrPr 01-24-2008 09:49 PM

Got ya
I created my tables this way

Thanks m8

--------------- Added [DATE]1201278626[/DATE] at [TIME]1201278626[/TIME] ---------------

One another question about bitmask and bitwise in DB and queries
I've multiple status for each entry on the table, such as SHOWN or HIDDEN, PREMIUM or FREE, ...
i can add one field for each status, for example 3 TINYINT(1) or BOOL fields
[SQL]
SELECT * FROM table WHERE `x`=1 AND `y`=0 AND `z`=1
[/SQL]


another method in my mind is use one TINYINT filed for all cases
INSERT and SELECT rows using AND(&) bit operand
for example
[SQL]
SELECT * FROM table WHERE `status`&5
[/SQL]
where 1 stands for x, 2 for y and 4 for z

which one is better? is there any difference in performance?

IrPr 01-29-2008 07:07 PM

my previous post had been auto merged
so accept my BUMP :D

Eikinskjaldi 01-29-2008 10:52 PM

Personally I am not a fan of bits because I find them and their code obfuscating. I aslo do not know which is quicker.

My suggestion is try it both ways and use explain and some test queries to see which is better.


All times are GMT. The time now is 07:35 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00963 seconds
  • Memory Usage 1,724KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete