database-schema

Implementing an efficient system of “unread comments” counters

拥有回忆 提交于 2019-12-05 02:10:16
I am trying to find an optimal solution for the following problem: there is a need to design a database (postgres-based), the system of triggers and counters in it, which will form a system of efficiently querying, updating and storing information on 'how much unread comments exist in each article (or blog entry, or smth. similar), that is displayed on the page'. Every solution that comes to the head, has some serious disadvantages, either in querying, or the storing, or the updating part. I.e. it needs too much storage, or too much updates, or too costy queries. What about your expirience?

How to get a list of all tables in two different databases

杀马特。学长 韩版系。学妹 提交于 2019-12-05 01:25:11
I'm trying to create a little SQL script (in SQL Server Management Studio) to get a list of all tables in two different databases. The goal is to find out which tables exist in both databases and which ones only exist in one of them. I have found various scripts on SO to list all the tables of one database, but so far I wasn't able to get a list of tables of multiple databases. So: is there a way to query SQL Server for all tables in a specific database, e.g. SELECT * FROM ... WHERE databaseName='first_db' so that I can join this with the result for another database? SELECT * FROM database1

Storing books in a database

大兔子大兔子 提交于 2019-12-05 01:04:27
问题 I want to create a system that stores books (and some other documents). Users will be able to log into the system where they can either see a list of all books or enter some search string and get a list of the books containing the search string. My problem is that I don´t know how I should go about storing my books. The books obv have to be searchable and the search needs to return the books ID, Name, and preferable page. Anything more like the text surrounding the search term would be a nice

how to get table's schema name

核能气质少年 提交于 2019-12-05 00:35:31
问题 I'm using SQL Server 2008 and have the following query: SELECT SO1.name AS Tab, SC1.name AS Col, SO2.name AS RefTab, SC2.name AS RefCol, FO.name AS FKName FROM dbo.sysforeignkeys FK INNER JOIN dbo.syscolumns SC1 ON FK.fkeyid = SC1.id AND FK.fkey = SC1.colid INNER JOIN dbo.syscolumns SC2 ON FK.rkeyid = SC2.id AND FK.rkey = SC2.colid INNER JOIN dbo.sysobjects SO1 ON FK.fkeyid = SO1.id INNER JOIN dbo.sysobjects SO2 ON FK.rkeyid = SO2.id INNER JOIN dbo.sysobjects FO ON FK.constid = FO.id How do

How can I create a MetadataWorkspace using metadata loading delegates?

☆樱花仙子☆ 提交于 2019-12-04 21:47:46
I followed this example Changing schema name on runtime - Entity Framework where I can create a new EntityConnection from a MetaDataWorkspace that I then use to construct a DbContext with a different schema, but I get compiler warnings saying that RegisterItemCollection method is obsolete and to "Construct MetadataWorkspace using constructor that accepts metadata loading delegates." How do I do that? Here is the code that is working but gives the 3 warnings for the RegsiterItemCollection calls. I'm surprised it works since warning says obsolete not just deprecated. public static

Design users table for single sign in to use across sub domains

不羁岁月 提交于 2019-12-04 21:37:54
问题 We have a site which has sub domains like: example.com - Main Site food.example.com fashion.example.com And each domain and sub domain has a different database, like this: exampleDB - Main DB with Users Table foodDB fashionDB What have you tried? Right now, for single sign in we have planned to redirect users in our Main Site for signing up. While order processing in sub domains get the UserID from main DB and store in respective sub domain's Orders table. For reporting purposes we store the

How to model many-to-many relationships in MongoDB (for a MySQL user)

夙愿已清 提交于 2019-12-04 19:19:46
问题 I come from a MySQL background and am trying to wrap my head around MongoDB . In particular, I'm struggling to conceptualize how I should model n:n relationships the "Mongo way." For this example, let's say we have two collections : users and interests . We need to be able to represent or query for several things in our data: User's interests User's rating of interest, e.g. "like" or "dislike" Users with a given interest Counter (which can be incremented/decremented) of each rating of the

Laravel - Creating tables dynamically (without migration)

大城市里の小女人 提交于 2019-12-04 17:02:23
问题 I'm trying to create a table dynamically upon an admin request, and while it seems all fun and dandy like in most of Laravel's documentation, I can't seem to create a table. Though I can drop tables, and add or drop columns as I wish. This is my basic code model: use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; public static function createTable() { Schema::create('randomName', function($table) { $table->increments('id'); $table->string('name'); }); } What

Sequelize: Changing model schema on production

ε祈祈猫儿з 提交于 2019-12-04 16:44:26
问题 We're using the orm sequelize.js and have defined a model as such: module.exports = function(sequelize, DataTypes) { var Source = sequelize.define('Source', { name: { type: DataTypes.STRING, allowNull: false, unique: true } }, { paranoid: true }); return Source; }; This is deployed to production and sync'd to the database using sequelize.sync . Next step, we add a parameter: module.exports = function(sequelize, DataTypes) { var Source = sequelize.define('Source', { name: { type: DataTypes

What is the difference between an Oracle and Microsoft schema?

丶灬走出姿态 提交于 2019-12-04 16:28:28
问题 I am working on an enterprise project. Some members of the team have an Oracle background and some have a Microsoft SQL Server background. There is much confusion when we talk about schemas. I am trying to provide some clarity. Is this an accurate way to describe the difference in the meaning of schemas between the two technologies? An Oracle schema is associated with a single user and consists of the objects owned by the user. A MS SQL Server schema is a namespace. 回答1: Oracle schemas are