我有3个不同的事务表,看起来非常相似,但有一点点差异.这是因为有3种不同的交易类型; 取决于列更改的事务类型,因此要在3NF中获取它们,我需要将它们放在单独的表中(对吗?).
例如:
t1:日期,用户,金额
t2:日期,用户,谁,金额
t3:日期,用户,内容,金额
现在我需要一个查询,它将为每个表中的同一个用户提供所有事务,例如
select*from t1,t2,t3,其中user ='me'; (这当然不起作用).
我正在研究JOIN语句,但没有正确的方法来做到这一点.谢谢.
编辑:其实我需要每个表中的所有列,而不仅仅是那些相同的列.
编辑#2:是的,当然,拥有transaction_type并不会破坏3NF - 所以也许我的设计完全错了.这是真正发生的事情(它是一种替代货币系统):
- 交易在用户之间,如相互信用.因此,单位在用户之间交换.
- Inventarizations是带入系统的物理内容; 用户获得此单位.
- 消耗是消耗的物质; 用户必须为此付费.
|--------------------------------------------------------------------------| | type | transactions | inventarizations | consumations | |--------------------------------------------------------------------------| | columns | date | date | date | | | creditor(FK user) | creditor(FK user) | | | | debitor(FK user) | | debitor(FK user) | | | service(FK service)| | | | | | asset(FK asset) | asset(FK asset) | | | amount …
也许我忽略了一些非常容易和明显的事情......
我有一个类似的方法接口
private void render(Collection<Object> rows);
Run Code Online (Sandbox Code Playgroud)
现在,我需要传递的对象是一个数组(来自枚举):
Module[] mods = Module.values();
widget.render(mods);
Run Code Online (Sandbox Code Playgroud)
当然这不起作用,但为什么这不起作用:
widget.render(Arrays.asList(mods))
Run Code Online (Sandbox Code Playgroud)
它将我的数组转换为Module的集合,而Module是一个对象......
try
p = req.params.name
Item.update('name': p, req.body , {upsert: true}, (err) ->
if err?
throw err
res.send("ok")
)
catch e
handle_error(e, "Error salvando hoja de vida.", res)
Run Code Online (Sandbox Code Playgroud)
这在我的代码中产生了一个错误 - 这没关系,但是为什么我的nodejs程序崩溃,即使我在这里试试了?
错误是:
MongoError: Mod on _id not allowed
Run Code Online (Sandbox Code Playgroud)
(所以它必须在更新调用中)我特意寻找一种捕获错误的方法,我已经知道如何摆脱它.
如果您将video标签放在页面上,除了src(只是一个onclickJavaScript 处理程序)之外没有太多其他属性,浏览器的通常行为是什么?他们会完整下载视频吗?只是一些框架?这个浏览器有特定的吗?
我被要求审查一个网站,该网站展示了很多视频,所以我只是很好奇。
我有一个[]byte我需要按升序排序的东西.
我得到一个带有项目的对象,然后迭代数组以创建返回的对象:
// unfortunately, for some obscure reason I can't change the data types of the caller and the object from the function call are different, although both are []byte underneath (...)
type ID []byte
// in another package:
type ByteInterface []byte
func (c *Store) GetAll() ByteInterface {
returnObj := make([]ByteInterface,0)
obj, err := GetData()
// err handling
for _, b := range obj.IDs {
returnObj = append(returnObj, ByteInterface(b))
}
return returnObj
}
Run Code Online (Sandbox Code Playgroud)
所以我问自己是否可以这样做,append以便立即returnObj排序,或者我是否需要 …
我在项目中的前任没有在表格中保存下拉列表值; 他们在html文件中...这家伙也没有$form->dropdownList()用来创建选择......
当然,我现在遇到了在编辑时预先选择值的巨大问题; 因此,我改变了所有<select>到$form->dropdownList().
但现在我有一个不同的问题,如
echo $form->dropdownList($model,'location',
array("Art","Gallery","Bar","Club"));
Run Code Online (Sandbox Code Playgroud)
现在为DB生成整数值...
我知道我可以像这样设置显示值:array("Art"=>"Art")....但我宁愿避免这种情况 - 有一堆视图直接显示值...... :(
有没有办法告诉yii DB值应与显示值相同?
我正在使用护照登录.我想要除了'/'要求登录之外的所有路线.
我有一个
ensureAuthenticated
Run Code Online (Sandbox Code Playgroud)
功能,检查我是否经过身份验证.
我宁愿不想把中间件调用放到每个路由中:
app.get('/first', ensureAuthenticated,...)
app.get('/second', ensureAuthenticated,...)
Run Code Online (Sandbox Code Playgroud)
有没有办法分配ensureAuthenticated给所有路线除外'/'?
我有一个当前没有收到bool参数的函数,但随后用硬编码的bool调用另一个函数.我们需要删除硬编码调用并允许传递bool.
我首先想到我可以尝试一些默认参数 - 我的谷歌搜索导致Go显然不支持可选(resp.default)参数.
所以我想我会尝试函数重载.
我在reddit上发现了这个帖子,它表示它可以使用特殊指令,因为版本1.7.3:https:
//www.reddit.com/r/golang/comments/5c57kg/when_did_function_overloading_get_slipped_in/
我正在使用1.8,但我仍然无法获得它工作.
我甚至不确定我是否可以被允许使用该指令,但我猜测立即更改功能签名可能很危险,因为我不知道谁使用该功能......
无论如何 - 即使// +重载它也没有用
Go中是否有任何"特殊"方式或模式来解决这个问题?
//some comment
//+overloaded
func (self *RemoteSystem) Apply(rpath, lpath string, dynamic bool) error {
result, err := anotherFunc(rpath, dynamic)
}
//some comment
//+overloaded
func (self *RemoteSystem) Apply(rpath, lpath string ) error {
//in this function anotherFunc was being called, and dynamic is hardcoded to true
//result, err := anotherFunc(rpath, true)
return self.Apply(rpath, lpath, true)
}
Run Code Online (Sandbox Code Playgroud)
当我运行我的测试时,我得到(原谅我省略了部分真正的文件路径):
too many arguments …Run Code Online (Sandbox Code Playgroud) 我有两个相同的结构,为消除歧义的目的有不同的类型:
type BaseType struct {
id uint64
name string
}
type LabeledType1 BaseType
type LabeledType2 BaseType
Run Code Online (Sandbox Code Playgroud)
整个链中有一个功能实际上并不关心LabeledType它,它只适用于BaseType(因为它与两者完全相同).事件的发送者必须发送标记类型,而不是基类型,因为实际类型定义了一些后行为.
func handle(evt interface{}) error {
switch e := evt.(type) {
case *LabeledType1:
return handleBaseEvent(e)
case *LabeledType2:
return handleBaseEvent(e)
//there are other types
case *OtherType:
return handleOtherType(e)
}
}
func handleBaseEvent(evt *BaseType) {
//do stuff
}
Run Code Online (Sandbox Code Playgroud)
现在当然这不编译:
cannot convert e (type *LabeledType1) to type BaseType
Run Code Online (Sandbox Code Playgroud)
但我想知道,就我理解这个概念而言,这两种类型都是可分配的,所以应该有一些简单的转换?我尝试过类型转换:
evt.(BaseType))
并且
BaseType(e)
我不能用bool里面的东西BaseType.
我有一个哈希:
b := hash.Sum(nil)
Run Code Online (Sandbox Code Playgroud)
我真的只对该字节的第一位感兴趣。是0还是1?
到目前为止我有这个:
s := strconv.FormatInt(int64(b[0]),2)
if s[0] == '0' {
// it's 0
} else {
// it's 1
}
Run Code Online (Sandbox Code Playgroud)
但我确信有一种更优雅(也更高效?)的方法来做到这一点。