database-schema

Mongoose / MongoDB - Simple example of appending to a document object array, with a pre-defined schema

霸气de小男生 提交于 2019-12-03 10:03:39
问题 For the sakes of simplicity, assuming these are my collection schemas: var MessageDeliverySchema = new Schema({ from : { type : String }, to : { type : String }, status : { type : String } }); var Messages = mongoose.model('messages', new Schema({ id : ObjectId, user : { type:String }, 'sent-messages' : [MessageDeliverySchema] })); So each document in the collection Messages may have 4/5 sent-messages defined by the MessageDeliverySchema. What I want to do is have an array of sent-messages ,

Replicate a single table

瘦欲@ 提交于 2019-12-03 09:57:06
Is it possible to replicate a single table? Yes this is possible. Have a look at the slave options of the MySQL manual. This still requires to create a complete binlog of the whole database though. To sync specific tables again to one or more slaves rather use pt-table-checksum and then pt-table-sync That should automatically identify the out-of-sync tables and only sync those. Scarecrow I know this is an old question but this is for anyone who comes here looking for an answer: CREATE TABLE table2 LIKE table1; This will create a table with the same format and columns but no data. To transfer

Sequelize: Changing model schema on production

风流意气都作罢 提交于 2019-12-03 09:51:06
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.STRING, allowNull: false, unique: true }, location: { type: DataTypes.STRING } }, { paranoid: true });

“Relation” versus “relationship” in RDBMS/SQL?

瘦欲@ 提交于 2019-12-03 08:42:47
Coming from question “Relation” versus “relationship” What are definitions of "relation" vs. "relationship" in RDBMS (or database theory)? Update: I was somewhat perplexed by comment to my question: "relation is a synonym for table, and thus has a very precise meaning in terms of the schema stored in the computer" Update2: Had I answered incorrectly that question , in terms of RDBMS, having written that relation is one-side direction singular connection-dependence-link, i.e. from one table to another while relationship implies (not necessarily explicitly) more than one link connection in one

Grant all privileges to user on Oracle schema

不羁的心 提交于 2019-12-03 07:50:41
Is there a way to grant all privileges to a user on Oracle schema? I tried the following command but it only grants permission on specific tables in a schema. What I want is to give this user all permissions on a given schema. GRANT ALL ON MyTable TO MyUser; Wernfried Domscheit You can do it in a loop and grant by dynamic SQL: BEGIN FOR objects IN ( SELECT 'GRANT ALL ON "'||owner||'"."'||object_name||'" TO MyUser' grantSQL FROM all_objects WHERE owner = 'MY_SCHEMA' AND object_type NOT IN ( --Ungrantable objects. Your schema may have more. 'SYNONYM', 'INDEX', 'INDEX PARTITION', 'DATABASE LINK',

Want to restrict the value of a MySQL field to specific range (Decimal values)

柔情痞子 提交于 2019-12-03 07:45:01
I want to restrict the value of a field in a row of a table to a specific range. Is it possible to restrict my relationship_level field to [0.00 to 1.00] ? At the moment I am using DECIMAL(2,2), it wouldn't allow DECIMAL(1,2) as M must be >= D. I assume a data type of DECIMAL(2,2) will actually allow values from 00.00 up to 99.99? CREATE TABLE relationships ( from_user_id MEDIUMINT UNSIGNED NOT NULL, to_user_id MEDIUMINT UNSIGNED NOT NULL, relationship_level DECIMAL(2,2) UNSIGNED NOT NULL, PRIMARY KEY (from_user_id, to_user_id), FOREIGN KEY (from_user_id) REFERENCES users (user_id) ON DELETE

Database Structure involving dynamic fields

情到浓时终转凉″ 提交于 2019-12-03 07:40:00
问题 Im working on a project. Its mostly for learning purposes, i find actually trying a complicated project is the best way to learn a language after grasping the basics. Database design is not a strong point, i started reading up on it but its early days and im still learning. Here is my alpha schema, im really at the point where im just trying to jot down everything i can think of and seeing if any issues jump out. http://diagrams.seaquail.net/Diagram.aspx?ID=10094# Some of my concerns i would

How to share a table between multiple Postgresql databases

只愿长相守 提交于 2019-12-03 07:20:50
问题 My web app has multiple deployments -- each is a unique site with a unique URL. Each deployment has different data, UI, etc. but a very similar Postgresql database structure (with PostGIS). The databases all live on the same DB server. I would like users from 1 deployment to be able to log in to all other deployed apps without having to re-register. What I want is a single "users" table that is shared across multiple app databases. Any user who registers in one app should be recognized by all

Tagging system: Toxi solution questions

◇◆丶佛笑我妖孽 提交于 2019-12-03 06:06:36
问题 I'm sort of breaking my head over the Toxi solution for tag database schemas. I'm working on a system to which users can submit items, and those items can have tags associated with them. After reading up on tagschemas, I found the Toxi solution to suit my needs most. However, I'm not entirely sure if I'm planning this right, so I'd like your opinions on this please. I'll have three databases. items containing item_id and others tagmap using item_id and tag_id as foreign keys tags containing

Data Modeling: Supertype / Subtype

旧城冷巷雨未停 提交于 2019-12-03 05:25:39
问题 Looking to figure out the proper way to model the below requirements. There are 3 types of “parties” to be concerned with, a Fan, a Band, and a BandMember. That BandMember will always be associated with a Band and can also be a Fan of any band. There are common attributes between a Fan, a Band, and a BandMember, but each of these 3 will also have their own unique attributes. A Fan can be a fan of of any Band or none at all This is a small part of a bigger thought but it is creating confusion