我知道有一些相关的帖子,但我不完全明白该怎么做.
我对如何解决这个问题有一个大概的了解.不幸的是,我对数据库设计并不太了解,所以我需要帮助.
拥有带有questions_id的表,为每个question_id提供for_answer_id表.
然后有一个链接表question_answers with user_id,question_id,answer_id,timestamp来注册提交的表单.
但我的问题是,一些问题只用一个字符串来回答,所以我无法概念化该怎么做.
e,g for some I need: question_id string_answer (any answer is allowed) for others: question_id answer_id (out of set of allowed answers) and perhaps: question_id bool_answer (true/false)
我是否在某处添加了question_type,因此我有两个不同的表格?
如果问题不明确,请告诉我.
我试图将C++连接到MySql,但我无法让它正常工作.我从Oracle站点使用了最新的MySql和C++/Connector for Windows.我也用VS2010.
它编译,一切都工作除了getString!我使用了他们提供的一些调整示例:
#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <driver/mysql_public_iface.h>
#include "examples.h"
using namespace std;
int main(int argc, const char **argv)
{
string url(argc >= 2 ? argv[1] : EXAMPLE_HOST);
const string user(argc >= 3 ? argv[2] : EXAMPLE_USER);
const string pass(argc >= 4 ? argv[3] : EXAMPLE_PASS);
const string database(argc >= 5 ? argv[4] : EXAMPLE_DB);
/* sql::ResultSet.rowsCount() returns size_t */
size_t row;
stringstream sql;
stringstream msg;
int i, affected_rows;
cout << boolalpha; …Run Code Online (Sandbox Code Playgroud) std::auto_ptr< sql::Statement > stmt(con->createStatement());
Run Code Online (Sandbox Code Playgroud)
我查看了我的教科书,但没有提到任何类似的东西.有人能告诉我它叫什么,所以我可以查一查吗?我所知道的"<"的唯一用途是作为二进制less-then运算符.