What mysql database tables and relationships would support a Q&A survey with conditional questions? [closed]

Survey Database Design Last Update: 5/3/2015 Diagram and SQL files now available at https://github.com/durrantm/survey If you use this (top) answer or any element, please add feedback on improvements !!! This is a real classic, done by thousands. They always seems ‘fairly simple’ to start with but to be good it’s actually pretty complex. To do … Read more

Adding an one-out-of-two not null constraint in postgresql

You can use a check constraint e.g. constraint chk_education check (schoolName is not null or studiedAt is not null) From the manual: A check constraint is the most generic constraint type. It allows you to specify that the value in a certain column must satisfy a Boolean (truth-value) expression. Edit: Alternative to comply with Pithyless’ … Read more

Is it possible to create a column with a UNIX_TIMESTAMP default in MySQL?

The way MySQL implements the TIMESTAMP data type, it is actually storing the epoch time in the database. So you could just use a TIMESTAMP column with a default of CURRENT_TIMESTAMP and apply the UNIX_TIMESTAMP() to it if you want to display it as an int: CREATE TABLE foo( created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP … Read more

DB2 Query to retrieve all table names for a given schema

–for DB2/z select * from sysibm.systables where owner=”SCHEMA” and name like ‘%CUR%’ and type=”T”; –for DB2/LUW select * from sysibm.systables where CREATOR = ‘SCHEMA’ and name like ‘%CUR%’ and type=”T”; This will give you all the tables with CUR in them in the SCHEMA schema. See here for more details on the SYSIBM.SYSTABLES table. If … Read more

Should I use a single or multiple database setup for a multi-client application? [closed]

I usually add ClientID to all tables and go with one database. But since the database is usually hard to scale I will also make it possible to run on different database instances for some or all clients. That way you can have a bunch of small clients in one database and the big ones … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)