首页 \ 问答 \ SQL:SQL数据库中的链接列表?(SQL : Linked lists in SQL database?)

SQL:SQL数据库中的链接列表?(SQL : Linked lists in SQL database?)

有一个结构问题,我不知道如何准确解决。

我正在做一个库存系统 - 应该支持多个商店,每个商店都有自己的商品数据库,前100个商店有50.000个商品号。

itemnumber数据库是全局的(所有商店都是相同的itemnumbers) - 但由于我需要跟踪每个商店的库存数量,我假设我需要为每个商店创建一个本地副本,那就是很多表和很多冗余数据。

但令我头疼的是,对于每个库存(他们从整个库存计算完整的商店) - 我需要添加新的库存数量pr项目编号(和一些结果字段,更正库存与原始库存等) - 这是应该添加的东西每次他们选择完成补货/重新计票。

假设itemdatabase是:

itemno,description,现在总库存

然后对于新的库存,当它完成时我需要将这3个值添加到记录中 - 如果他们选择做ex。 200个库存计数我需要在每个项目中添加200个这样的集合:

库存积分,总计数,差异(总计数 - 总计数)

因为我必须能够为每个新的重新进货/重新计数(库存会话)执行此操作,并将每个结果保存为事件历史记录,所以我不能(我认为)在SQL中将动态字段添加到当前表结构中。

如果我有某种链表,我可以让它在我的脑海里工作 - 其中itemrecord上的链表代表了库存会话的字段集 - 所以不是将50.000条记录的完整副本复制到另一个表中对于每个库存会话,我将能够通过包含2的链表扩展表。

另一个选择是某些关系的东西,我想有几个表,但这变得复杂,我担心它需要的所有查找。

是否有可能以正确的方式在SQL数据库中以某种方式使用链表结构或此类问题? 或者你会建议我使用另一个数据库而不是SQL?


Have a structual question i dont know how to solve exactly.

Im doing an inventory system - where there should be support for multiple stores, each with their own item database, ex 100 stores with 50.000 itemnumbers.

The itemnumber database is global ( same itemnumbers for all stores ) - but since i need to keep track on stock count in each store, i assume i would need to create a local copy per shop, thats alot of tables and alot of redundant data.

But my headache is that for each inventory ( they count the complete shop from scrath ) - i need to add the new stockcount pr itemnumber ( and some result fields, corrected stock vs original stock etc. ) - and this is something that should be added each time they choose to do a complete restock/recount.

lets say the itemdatabase is :

itemno, description, total stock now

Then for a new inventory when its completed i need to add these 3 values to the record - if they chose to do ex. 200 inventory counts i would need 200 of these sets to be added per itemnumber :

inventorysession,total count, difference (total count - total count)

Since i have to be able to do this for each new restock/recount (inventory session), and keep the results for each as a history of events, i cannot ( i think ) in SQL add dynamic fields to the current table structure.

I could get it to work in my mind if i had some kind of linked list - where the linked list on the itemrecord would represent the sets of fields pr inventory-sessions - so instead of making a complete copy of the 50.000 records into another table for each inventory session, i would be able to extend the table throuh a linked list which would contain the 2.

Another option would be some kind of relational thing with several tables i guess, but that gets complicated and i worry about all the lookup's it would require.

Is it possible in a correct way to somehow use a linked list structure or this kinda of problem in a SQL database ? or would you advice me to use another database instead of SQL ?


原文:https://stackoverflow.com/questions/37098131
更新时间:2021-12-05 08:12

最满意答案

确保:

1) Postgres db is running
2) pg is installed: 

npm install --save pg

3) Add also protocol to your config
'dialect':'postgres',
'protocol':'postgres'

Make sure:

1) Postgres db is running
2) pg is installed: 

npm install --save pg

3) Add also protocol to your config
'dialect':'postgres',
'protocol':'postgres'

相关问答

更多
  • 经过多次调试,我找到了解决方案 app.get('/users', (req, res) => { User.findAll({ where: { '$Task$': null, }, include: [ { model: Task, required: false, }, ], }).then(function(todo) { res.json(todo); }); }); 通过添加此w ...
  • 所以从理论上讲你的代码片段应该可行,但是sequelize代码会抛出一个我怀疑会误导的错误。 您需要编辑lib/transaction-manager.js文件,因为它会吞下您需要的错误详细信息。 在throw之前在catch块中添加一个console.error(err) ,以确保错误不是别的奇怪,就像你的sequelize安装缺少文件或没有正确处理Windows路径或类似的东西。 进行一次更改,重新运行您的代码段,并使用详细信息更新您的问题,如果这不会直接导致根本原因和解决方案。 So in theor ...
  • 使用字段更新您的模型,它会没事的 var Milestones = sequelize.define('milestones', { milestoneId: { type: Sequelize.INTEGER, field: 'milestoneId' }, data: Sequelize.JSON, repository: Sequelize.STRING }); 编辑: 也用更新订单 order: ['milestoneId'] Update your model ...
  • 您无法使用箭头功能,因为他们无法访问this 。 尝试像这样写他们 - // Instance methods User.prototype.testFunction = function testFunction() { this.firstName = "John"; } // Class methods User.anotherTestFunction = function anotherTestFunction() { User.findOne().then(() => doSomethi ...
  • 在创建表(在数据库中)后添加了关系吗? 如果您修改了您的方案并再次运行您的程序,则需要.sync({ force: true }) 。 如果数据库中尚不存在该表,Sequelize将只创建该表及其所有引用。 在所有关联完成后您是否调用同步? 你在使用InnoDB吗? 奇怪的是,我可以重现,最简单的解决方法是手动定义密钥,我认为,这就是我解决它的方法,可能是一个错误,否则我不确定。 请参阅: http : //sequelizejs.com/docs/latest/associations#block-3-l ...
  • 确保: 1) Postgres db is running 2) pg is installed: npm install --save pg 3) Add also protocol to your config 'dialect':'postgres', 'protocol':'postgres' Make sure: 1) Postgres db is running 2) pg is installed: npm install --save pg 3) Add also protoco ...
  • 最后想想这个问题 ,感谢Sean在这个Stackoverflow问题中给出的答案 - 我在bin中为我的数据库连接(db.js)创建了一个新文件,并导出了sequelize doing module.exports = sequelize; 然后我就可以在执行var sequelize = require('../../../bin/db'); 我仍然不确定为什么我的早期方法不起作用 - 当我在其他文件中需要它时,bin / www的导出返回了一个空对象。 我认为这与异步行为有关,因为当我启动nodemon ...
  • 你只需在初始化sequelize时提供方言; const sequelize = new Sequelize('database', 'username', 'password', { host: 'localhost', dialect: // pick one of 'mysql','sqlite','postgres','mssql', }); You simply supply the dialect when you initialize sequelize; const sequeli ...
  • 看起来您的NODE_ENV与development , test或production ,因为如果它与任何一个匹配,您将获得类似的消息 Loaded configuration file "config/development.json". Using environment "development". Unable to connect to database: SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306 但 ...
  • 要使用CLI,您需要安装相应的包: npm install --save sequelize-cli 有关可用命令的更多详细信息可以通过help命令获得: $ sequelize help:init $ sequelize help:db:migrate $ sequelize help:db:migrate:undo 有关更多信息,请使用此链接Sequelize In order to use the CLI you need to install the respective package: np ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)