« first day (1335 days earlier)      last day (1323 days later) » 

2:11 AM
@xyz Looks like jorge gave a good answer
 
 
3 hours later…
5:28 AM
I'm modeling a Game, and I want to account for the fact that some people play timed and and some people play untimed
If someone is playing timed, I need a attribute of how many minutes long ]their game is
Do I have an attribute minutesLong that is null for untimed but some positive quantity for timed?
Should I have a boolean timed attribute as well?
I've heard conflicting messages on whether/how to use null in databases, so I'm not sure
 
 
8 hours later…
1:04 PM
what does auto increment do in database when two operations at the same time inserts a record?
 
 
3 hours later…
m59
4:32 PM
    JOIN(
      SELECT COUNT(*) as count
      FROM channel
      JOIN story ON story.channel_id = channel.id
      WHERE channel.url = ?
    ) AS total_items
Is this ok?
COUNT(*) in the main query was all kinds of wrong.
or does that mean my main query is messed up?
 
@m59 that's reasonable as long as your main query is just returning one row
 
m59
it returns many :/
 
@m59 nah, not necessarily. Likely just a case of the grouping pitfall
@LeeJeong there is a very low-level mutex on the auto-increment value - one of the two operations gets one id, and the other operation gets the other id.
@LeeJeong that's part of the reason why even if a transaction is cancelled, the auto-increment values that it would have used are still gone.
2
 
question...
can you code-review this forward-engineered script?
ERROR: Error 1054: Unknown column 'product_id' in 'OLD'
SQL Code:
CREATE TRIGGER `Product_BDEL` BEFORE DELETE ON `product` FOR EACH ROW
BEGIN
INSERT INTO `product-audit`
(`product-audit`.product_id,
`product-audit`.product_code,
`product-audit`.product_name,

`product-audit`.product_price,
`product-audit`.product_count

)

values
(OLD.product_id,
OLD.product_code,
OLD.product_name,

OLD.product_price,
OLD.product_count

);
END
 
4:43 PM
@m59 so my first question is, what's the primary key of your result set, and the answer is that it's the same as a story
 
i dont seem to see where the problem is
@TehShrike can you help me, cant find anything on google. :(
 
@LeeJeong does that error happen when you try to create the trigger, or when the trigger executes?
@LeeJeong MySQL I assume?
@m59 ah, you want to do groupwise max on the revision table
Never mind, your max_revision_times subquery is doing that
@m59 how many of those joins are many-to-one? I'm guessing most?
 
when i try to create the trigger..
yes.. mysql good sir
 
@m59 you can probably get away with COUNT(DISTINCT story_promotion.user_id) and whatever the equivalent is for your channel table
@LeeJeong What's the CREATE TABLE query for the product table?
 
FYI, when i removed the product.id form the INSERT clause and VALUES clause, it worked...
CREATE TABLE `product` (
`product.id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT COMMENT 'represents unique identifier for every existing products',
`product_code` varchar(20) NOT NULL,
`product_name` varchar(45) NOT NULL COMMENT 'description',
`product_price` decimal(11,4) NOT NULL,
`product_short-name` varchar(10) NOT NULL COMMENT 'name that can be used quickly to referenc or immediately know what is the product',
`product_count` bigint(20) unsigned NOT NULL DEFAULT '0',
`product-type_id` smallint(5) unsigned NOT NULL DEFAULT '0',
@TehShrike
 
4:52 PM
@LeeJeong ah, well there you go - you want OLD.id, not OLD.product_id
@LeeJeong or no, wait - that'd be OLD.product.id
That's going to be confusing.
I would highly recommend that you avoid dashes and periods in your identifier names
 
. i actually removed the (.)
 
OLD.product.id
hmm, stripping the tildes
 
idk, why its still there... i auto generated the script i posted
 
it must still be in the table?
 
i'll check again..
background info, ive been employing this format
table-name_column-name
i.e product-type_name
idk if im going daredevil or what
it serves the purpose of easy reading and understanding of my script when it involves joining
 
4:55 PM
Having the table name in the column name is redundant, I would recommend not doing that
Unless you're referencing a different table - like your product table could have a product_type_id
 
yeah.. i read it was a "SMURF" joke
 
In any query that uses more than one table, just use the table identifier
SELECT product.count instead of SELECT product_count
 
this what happened
 
If your query uses more than two tables, you should never have a column identifier without a table identifier attached
 
i dropped the old schema... where the product.id exist..
and then forward engineered the new product-id column name
the trigger worked.
as for the other issue of using hyphens and being redundant... what best practice could you offer..
 
m59
5:00 PM
@TehShrike DISTINCT defeats the purpose, because LIMIT affects it.
I thought I did this properly so as to avoid the groupwise problem...
 
@LeeJeong just what I said above - in every query, reference table_name.column_name, and don't prepend the table name to the column names
@m59 for story_revision, yeah (assuming you have a unique key on story_revision.story_id,story_revision. time_submitted)
 
well the advantage of this is on joins... when select * from product JOIN product-type ON product.product-type_id = product-type.product-type_id
 
but I'm guessing that story_promotion and story_cover_image can each have multiple rows per story
 
m59
promotion can
that's what's screwing with it?
 
@TehShrike i can clearly see and know that these columns are really matching.. avoiding the confusing product.product-type_id = product-type.id
 
5:03 PM
@LeeJeong If it's a foreign key, yeah, prepend the table name - but don't prepend the table name of the table that the column is in
 
m59
So, I sub-query out the promotions?
 
@LeeJeong I would recommend having the primary key be table_name_id, which would make that product.product_type_id = product_type.product_type_id
@m59 yeah, I'd recommend getting that query to where it doesn't require a GROUP BY
in the main query
 
@TehShrike versus the use of dashes?
 
@LeeJeong dashes aren't very common, and I think they make it more confusing here. If you do use dashes, I would recommend not using underscores
 
@teh i would sound so stubborn if i force the idea of using dashes.. but i'll explain the reason behind it
 
5:07 PM
one sec
Personally, I would recommend for the product table: product_id, code, name, price, short_name, count, product_type_id, is_active
Though personally I'm fine with just naming the PK "id" as well
 
sticking to the idea of appending the table name to column names... i can have the distinction of where is the table name and column name... i.e. product-type_amount-type, where product-type is the table name and amount-type is the column name really
thank you so much for your effort for going this far... i love Stack Overflow, there isnt much people with such patience and generosity to help us noobs
well, as long as the asking noobs are respectful..
 
@LeeJeong you're welcome, glad to help :-)
 
taking notes from you:
1. i would avoid prepending table name to column names, BUT if its Foreign key, do so.
2. avoid using of dashes (i read so much that this is a headache)..
@TehShrike is this correct?
 
@LeeJeong yup! and make sure to include table identifiers in every query that references more than one table.
as a bonus tip, I would very highly recommend avoiding pluralizing any table name. Just never put an "s" at the end of a table name.
 
3. on joins, its best practice to use the table identifier on columnnames
 
5:12 PM
You don't want to be referencing products_id
 
THAT I HIGHLY AGREE too!
 
@LeeJeong not just joins, but every single column reference - in the SELECT, in the WHERE, in the JOINs, everything
 
ahh, yes.. sorry. haha
thank you... NOW im off to modifying a HECK of tables and change their column names and stuff
 
m59
since I learn by talking (typing might suffice), let me try this:
The problem is that I have primary key "story.id" where that is referenced elsewhere in various ways
like "story_promotion.story_id" and so on
those tables might reference the same story.id several times
In which case, if my query is grouping by story.id, the other tables story_id will count as well
 
5:29 PM
@m59 can you explain that last line?
 
m59
nope
and my attempt didn't work so I must have gotten lost somewhere ;D
 
:-)
let's pair-code through the query
have a preference for voice-chat/screensharing?
 
m59
Skype?
 
sure, let me install it
 
m59
m59peacemaker
 
6:04 PM
hey!
is code and name reserved keywords for mysql
ERROR: Error 1235: This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table'
 
m59
6:23 PM
I'd pin that SQLYog message ;D
I can't go on not having named parameters in node mysql
What should I name this module?
it's called mysql-named-params-escape right now haha
I guess that's not bad.. (it's clear)
 
@LeeJeong yup. You can only have one trigger per action time/event.
 
@TehShrike saw it already... i saw it was not there, i just wondered why my column names turned blue when i was creating my triggers
 
@m59 Where are the tests? :-o
@LeeJeong that's just your syntax highlighter recognizing them as the names of functions
 
but it was not foul right?
just finished changing my column names without the tablename prefix.
weeeeewww... do you have any tip on updating your database without destroying your FK constraints?
when i say update, its the DB structure..
(naming, data type, FK, triggers and stuff)
 
m59
@TehShrike what's a test?
fired
 
6:38 PM
:-P
what do you use for non-Angular testing?
 
m59
You'll die. I really don't know how to test my server api :/
 
I'd recommend tape
I use tape for unit tests. I don't have server api tests at the moment, but I've bookmarked servertest
 
m59
It's all just an express route to a query
 
For that param-escaping library you'd just need tape
 
m59
What I mean I don't know how to test is queries.
 
6:41 PM
oh, yeah, those are more difficult
 
m59
I've heard of that save point dealy
 
you pretty much need a database populated with test data to run tests against
 
m59
I wrote enough sample data to get by.
 
Are you able to automatically create the schema and populate it with your canned data in a single click?
 
m59
Yep
 
6:42 PM
Nice.
 
m59
node install/init like every 5 minutes sometimes haha
 
Then you can just use something like tape and write tests that use your DAO modules
and do the reset before every test or whatever
 
m59
Makes sense.
 
you've already done the hard part :-)
 
m59
Yeah, I'd blow up the database somehow
node install/init Let's blow 'er up agin!
 
6:51 PM
Hey all,
If someone has any experience with this, I have a friend looking for IT Consultants in London, can any body please tell me what's the best site to find the best out there. He wants me to suggest the best ONE that would get us good candidates, so that he may pay only for that. I was thinking about "Stackoverflow Careers", "The Guardian Jobs" or "Linkedin". What would you guys suggest?
 
@KamranAhmed when I was looking for a job, I just used Stack Overflow Careers
I don't know if there's a right answer. The best answer would probably be specific to the type of consultant, and lots of other variables like whether remote work was acceptable or not
 
@TehShrike that's what I have been using, but the question is whether it would be suitable for IT Consultant related posting :)
 
@KamranAhmed no clue :-)
 
No problem. Thanks :-)
 
7:17 PM
@TehShrike weeeeewww... do you have any tip on updating your database without destroying your FK constraints?
when i say update, its the DB structure..
(naming, data type, FK, triggers and stuff)
 
@LeeJeong what kind of alters? It doesn't seem like they should be too problematic, I wouldn't imagine that you'd often be renaming/removing a column that was a foreign key in a lot of other tables
 
here's one: wait a sec
ERROR: Error 1828: Cannot drop column 'product_id': needed in a foreign key constraint 'rfvpos/nozzle_productFK'
SQL Code:
ALTER TABLE `rfvpos`.`Nozzle`
DROP COLUMN `product_id`,
DROP COLUMN `name`,
DROP COLUMN `code`,
ADD COLUMN `code` VARCHAR(20) NOT NULL AFTER `nozzle_id`,
ADD COLUMN `name` VARCHAR(45) NOT NULL AFTER `code`,
ADD COLUMN `product_id` MEDIUMINT(8) UNSIGNED NOT NULL COMMENT 'this column should contain the ID of the fuel product it serves' AFTER `name`,
DROP INDEX `nozzle_productFK_idx` ,
I am trying to sync my Data Model to my DB...
 
@LeeJeong You should be able to use ALTER COLUMN or CHANGE COLUMN for those dev.mysql.com/doc/refman/5.5/en/alter-table.html
 
then its that.. should there be an order of dropping then replacing
 
unless you have to maintain production data in some schema, it seems like it would be easier to drop and re-create
 
7:21 PM
@TehShrike in my case, im developing my design on MySQL Model... then ctrl + shoft + z to synchornize it
 
@LeeJeong is that a MySQL Workbench tool?
 
yeah!
@TehShrike i wanted to alter my Model, then just sync it to my DB... is that possible.. i had some chances of success... but now its that...
@TehShrike i was able to sync it individually... idk whats wrong. lets call it a day.. goodnight/good morning.. thanks so much @TehShrike
 
7:37 PM
@LeeJeong What format is your model in?
Personally, I just work with CREATE TABLE statements and incremental ALTERs
I can understand the appeal in describing your schema with something a bit higher-level
 

« first day (1335 days earlier)      last day (1323 days later) »