标签: schema

存储字段作为单个文本类型JSON字符串与拆分到单独表的性能影响

我有一个叫做的表Billing,它基本上是一个收据(用于不同类型的交易).该应用程序具有一项功能,您可以创建新的费用(除税和其他常量以外的所有费用).由于会有一定数量的动态费用,我们决定将结算费用存储在具有JSON结构的单个文本字段中.所以该Charges列包含这样的东西:

{"CrateFee":50,"DeliveryFee":90,"PackagingFee":20}
{"DeliveyFee":90,"ServiceCharge":200}
Run Code Online (Sandbox Code Playgroud)

我们的替代方案是为这些费用创建一个单独的表格,具有以下结构:

Charges
BillingId | ChargeName |  ChargeValue
1           CrateFee      50
1           DeliveryFee   90
1           PackagingFee  20
2           DeliveryFee   90
2           ServiceCharge 200
Run Code Online (Sandbox Code Playgroud)

我们决定采用第二种方法,因为它会在一天内被数万行填充(估计一天内有大约一千笔交易).我知道如果我们使用第一个数据,我们将对数据的处理能力有限,所以我真的想推动单独的表方法.但是当我谈到数据库时,我不知道扩展,优化等等,所以我需要一些帮助.

可以使用第二种方法吗?这将如何影响性能?还有其他选择吗?

mysql sql database schema database-design

0
推荐指数
1
解决办法
150
查看次数

Facebook墙像MySQL结构问题

我不希望任何代码只是一个如何回答.

我正在尝试为webapp添加类似facebook的墙特征(不是商业的,只是实验性的).

我想到的第一件事就是存储类似"1/2011-10-10/texthere,2/2011-10-10/texthere"的内容,其中1将是id和2011-10-10的日期.然后我会在php中爆炸它并有一个数组.(然后搜索users表中的每个id等...)

但这有一些问题.一个是如果我有太多的帖子,它将对网页非常沉重,并且很难限制结果(没有谈论阵列的字符限制).

所以我想到了另外两个对我有利有弊的解决方案.

  • 使用一个包含4列的表:海报ID,接收者ID,消息,发布日期

  • 每个用户一张桌子(绝望的解决方案:))

那么,我应该直接去寻找我的第一个其他解决方案还是更好的解决方案呢?

谢谢

php mysql schema structure

0
推荐指数
1
解决办法
704
查看次数

如何保存PostgreSQL架构?

我需要将PostgreSQL数据库的模式发送给客户.
我怎样才能做到这一点?
我在db目录中找不到它.

postgresql schema

0
推荐指数
1
解决办法
1595
查看次数

显示来自不同架构 Oracle 的约束

我知道 user_constraints 和所有约束,我尝试了类似的东西

select * from user_constraints
Run Code Online (Sandbox Code Playgroud)

但我想看到来自不同架构的约束?

编辑:我想显示来自某些模式的约束,而不是全部

oracle schema constraints

0
推荐指数
1
解决办法
3207
查看次数

更新一个字段时自动更改 Django 模型字段并冻结另一个字段的一次性只写?

onupdateDjango 的模型字段有参数吗?

例如,在带有 SQLAlchemy 的 Flask 中,可以使用onupdate=...数据库模式的参数执行以下操作db.Column()

import datetime

from flask import Flask
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    created_on = db.Column(db.Text, default=datetime.datetime.utcnow().isoformat())
    updated_on = db.Column(db.Text, default=datetime.datetime.utcnow().isoformat(), 
                           onupdate=datetime.datetime.utcnow().isoformat())
Run Code Online (Sandbox Code Playgroud)

文档中,有一个auto_now参数,与onupdate=...SQLAlchemy 中的参数相同db.Column()

我已经尝试使用以下模型对象来模拟上面的 Flask 代码,但是如何onupdate=...在 Django 中获得相同的“效果”?

from django.db import models
from django.utils.timezone import now

class User(models.Model):
    id = models.IntegerField()
    created_on = models.DateTimeField(default=now)
    updated_on = …
Run Code Online (Sandbox Code Playgroud)

python django schema flask sql-update

0
推荐指数
1
解决办法
1823
查看次数

获取包含某个表名的所有模式的列表

我看过这些问题:

但他们都没有完全回答我的问题。我正在尝试搜索整个 PostgreSQL 数据库并列出其中包含“组”表的每个模式的名称。

我在想这样的事情:

SELECT * FROM information_schema.tables WHERE table_name='groups';
Run Code Online (Sandbox Code Playgroud)

但这仍然缺少如何获取包含模式。

sql database postgresql search schema

0
推荐指数
1
解决办法
902
查看次数

在 mongodb 中使用 $push 的一些错误

我的架构是

var User = new mongoose.Schema({
    //general information
    name : {type:String},
    email : {type : String},
    number : {type : String},
    password : {type:String},
    //featured information
    path: { type: String},
    dob : {type:String},
    gender : {type : String},
    blood_group : {type:String},
    marital_status : {type : String}
});

module.exports = mongoose.model('user',User);
Run Code Online (Sandbox Code Playgroud)

我想使用更新一些细节 -

app.post('/contactinfo',function (req,res) {
    var name = req.body.name;
    var number = req.body.number;
    var email = req.body.email;
    User.update({_id : userID},{
        $push : {
            name : name,
            number : number,
            email …
Run Code Online (Sandbox Code Playgroud)

schema mongoose mongodb node.js

0
推荐指数
1
解决办法
1149
查看次数

如何在Talend中动态猜测Mysqlinput中的模式

我已经构建了一个将数据从mysql db表复制到b mysql表的作业.表列是相同的,除非有时可以在表中添加新列.

我想从a到b中检索所有列,但只检索表b中存在的列.我能够在表b中存在查询特定的选择colume语句,如:

select coulmn1,column2,columns3... from table a
Run Code Online (Sandbox Code Playgroud)

问题是如果我在b中添加一个与mysqlinput中的talend作业模式匹配的新列,也应该更改因为我使用build in type.

有没有办法在作业运行期间强制架构列?

mysql schema jobs talend

0
推荐指数
1
解决办法
493
查看次数

SchemaCollection 上的多个 XSD:schemaElement 不能为空?

我正在尝试SchemaCollection在我的 Web 服务配置中使用 。但是当我为此添加代码时,我收到此错误:

引起:java.lang.IllegalArgumentException:schemaElement 不能为空!您是否运行 afterPropertiesSet() 或将其注册为 Spring bean?

这个错误是什么意思?查看Spring 代码,与schemaElementXSD 上的有关,但我无法说出什么。

没有 schemaCollection,一切正常。

完整错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pedidos' defined in class path resource [br/com/company/rdt/config/WebServiceConfig.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: schemaElement must not be null! Did you run afterPropertiesSet() or register this as a Spring bean?
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1631) ~[spring-beans-4.3.20.RELEASE.jar:4.3.20.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.20.RELEASE.jar:4.3.20.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481) ~[spring-beans-4.3.20.RELEASE.jar:4.3.20.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312) ~[spring-beans-4.3.20.RELEASE.jar:4.3.20.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.20.RELEASE.jar:4.3.20.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308) ~[spring-beans-4.3.20.RELEASE.jar:4.3.20.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) …
Run Code Online (Sandbox Code Playgroud)

schema spring xsd soap web-services

0
推荐指数
1
解决办法
2315
查看次数

ObjectId 的 NodeJS/Mongoose 模式数组

我正在尝试在 Mongoose 的架构中实现一个 ObjectId 数组。我在互联网上搜索,我发现这应该有效:

import mongoose from 'mongoose';
import Schema from 'mongoose';

const UserSchema = mongoose.Schema({
  nickName: {
    type: String,
    unique: true,
    required: true,
  },
  follows: [{
    type: Schema.Types.ObjectId, //HERE
    ref: 'User',
    default: []
  }],
}, {
  strict: true,
});

const User = mongoose.model('User', UserSchema);
export default User;
Run Code Online (Sandbox Code Playgroud)

或这个

follows: {
          type: [Schema.Types.ObjectId], // HERE
          ref: 'User',
          default: []
  },
Run Code Online (Sandbox Code Playgroud)

我知道它们并不完全相同,但不是在这两种情况下都工作,我有这个错误:

 Invalid schema configuration: `ObjectID` is not a valid type within the array `follows`.
Run Code Online (Sandbox Code Playgroud)

我不知道他为什么告诉我 ObjectID(带有大写“ID”)无效,因为我没有声明任何这些。

我怎样才能做一个 objectId 数组?我想要一个 …

arrays schema mongoose node.js objectid

0
推荐指数
1
解决办法
3844
查看次数