Tag Info

Hot answers tagged

3

First off, you do not want to use char(50). Use varchar(50) or just text. Read more: Any downsides of using data type “text” for storing strings? Assuming the following rules: Basic slugs never end with a dash. Duplicate slugs are suffixed with a dash and a sequential number (-123). Note that all of the following methods are subject to a race ...


2

A general rule of thumb is that you will have a table for each type of thing that you are recording information about. Each instance of a thing will be a record in a table. It would probably* be a terrible idea to have one table per user. Have one table with USERS and one table with THINGS. In the THINGS table you will have a foreign key which is a ...


2

SUGGESTION #1 Based on the WHERE clause, I highly recommend a compound index ALTER TABLE mytable ADD INDEX (md5,created_at); That way, all parts of the WHERE clause are answered by the index. SUGGESTION #2 Since you are imposing a limit of 200, collect the 200 keys first, then join the keys SELECT B.* FROM ( SELECT id FROM mytable WHERE md5 = ...


1

Your question implies that you're using a Kimball Star Schema approach. Option 1 implies a star schema while option 2 implies a more snowflaked design. Kimball argues against snowflaking your design. Therefore, go with option one. It will be easier for your report writers long term and newer in memory database technologies will take advantage of it. ...


1

There are two ways to do this. The fast, and the "academic". In pseudocode (change to fit your database) The fast/high performance way: CREATE TABLE Products ( ID INT , Name VARCHAR , PricePerKg DECIMAL NULL , PricePerMeter DECIMAL NULL ... etc... ) While this is not pure 5NF, it is FAST because all lookups of products can be done with a ...


1

I'd say that this is pretty standard stuff ; Create table employees (id int primary key, name varchar(100) -- Plus some additional columns ) Create table responsibilities (id int primary key, description varchar(100) ...


1

Go for md5(15) because it has better cardinality and ref always beats range in performance. You wrote LIMIT 200 without ordering clause. Just heads up.



Only top voted, non community-wiki answers of a minimum length are eligible