Method 1:
CREATE TABLE `ads` ( `idads` int(11) NOT NULL AUTO_INCREMENT, `idobject` int(11) NOT NULL, `ad_type` enum('SALE','RENT','NEWHOUSING','GBUY','LAND','FIXMOVE') DEFAULT 'SALE', ) CREATE TABLE `house` ( `id` int(11) NOT NULL AUTO_INCREMENT, `uid` varchar(15) DEFAULT NULL,
To select the 'SALE' data
SELECT * FROM ads a JOIN house h on (h.id = a.idobject) WHERE a.ad_type = 'SALE';
Method 2
CREATE TABLE `ads` ( `idads` int(11) NOT NULL AUTO_INCREMENT, `uid` varchar(15), CREATE TABLE `house` ( `id` int(11) NOT NULL AUTO_INCREMENT, `uid` varchar(15) DEFAULT NULL,
TO SELECT 'SALE' data:
SELECT * FROM ads a JOIN house h on (a.uid=h.uid);
The uid in method2 already has information about the data_type type.
I am a little embarrassed that the best thing is:
Method1 seems faster, but you need to specify ad_type = 'SALE';
Method2 seems simpler, you just need to join the uid, but it seems slower? It's true?
Which one is best practice? What's the best performance? Or no difference at all?
PS. I am normalizing the bulletin board because it will be connected to a table, table, newhousing table, etc. The board will store ads_start_date, ads_end_date and other useful information.