database-schema

Replicate a single table

萝らか妹 提交于 2019-12-04 15:54:18
问题 Is it possible to replicate a single table? 回答1: 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. 回答2: 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. 回答3: I know this is an old question but this is for anyone who comes here looking for an answer: CREATE

SQL Server Database schema versioning and update

做~自己de王妃 提交于 2019-12-04 14:33:41
For my application I have to support update scenarios and the database might be affected. I want to be able to update from an old version to the newest without installing intermediate versions. E.g. Suppose I have version A (the oldest), B (intermediate) and C (new version). I want to be able to update version A straight to version C. For the application files this is simple, I just replace the old with the new ones. However for the database I do not wish to generate a SQL Script to change the database schema from A straight to C, instead I want first apply a script to change the schema from A

How to set uniqueness at DB level for a one-to-many association?

不想你离开。 提交于 2019-12-04 13:52:08
问题 My problem is simple but I could not find any GORM syntax for this. Consider the following class: class Article { String text static hasMany = [tags: String] static constraints= { tags(unique: true) //NOT WORKING } } I want to have one unique tag name per article defined in my constraints but I cannot make it with the above syntax. Clearly I need in DB schema something like: create table article_tags (article_id bigint, tags_string varchar(255), unique (article_id , tags_string)) How can I do

Grant all privileges to user on Oracle schema

时光怂恿深爱的人放手 提交于 2019-12-04 13:15:07
问题 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; 回答1: 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

One table vs multiple tables

和自甴很熟 提交于 2019-12-04 12:35:05
I have the following tables: - posts - files - events - documents Every post, file, event, document can have comments. What is the better database scheme for this, and why ? First solution comments table (comment_id, author_id, comment) 4 tables to create relations (posts_comments(post_id, comment_id), files_comments(file_id, comment_id), events_comments(event_id, comment_id), documents_comments(document_id, comment_id)) Second solution comments table (comment_id, author_id, comment) items_comments (comment_id, parent_type (enum['post', 'file', 'event', 'document']), parent_id) What is a

Seeking Schema for vCard Data Elements

房东的猫 提交于 2019-12-04 10:06:21
问题 I need a relational database schema to store vCard ver 3 data elements. Rather than reading the RFC and designing one from scratch, I'm looking to see if someone who has already done this is willing to share their database design. 回答1: (http://i.stack.imgur.com/61qGU.png) This is my DB schema for a VCard 3.0. This works quite well with CardMe library, each type is mapped to a database table and the many-to-many / one-to-many relationships are enforced through foreign keys. CREATE DATABASE ERP

Creating PostgreSQL tables + relationships - PROBLEMS with relationships - ONE TO ONE

泪湿孤枕 提交于 2019-12-04 08:41:24
问题 So I am supposed to create this schema + relationships exactly the way this ERD depicts it. Here I only show the tables that I am having problems with: So I am trying to make it one to one but for some reason, no matter what I change, I get one to many on whatever table has the foreign key. This is my sql for these two tables. CREATE TABLE lab4.factory( factory_id INTEGER UNIQUE, address VARCHAR(100) NOT NULL, PRIMARY KEY ( factory_id ) ); CREATE TABLE lab4.employee( employee_id INTEGER

Best Way To Build A Multi-Notification System in PHP

安稳与你 提交于 2019-12-04 08:11:31
问题 I am currently working on a mobile app that lets you ask friends for favourites, it's a HTML5 frontend and a PHP backend. I am stuck as to what the best way is to build a notifications system, more-so the database schema than the actual code itself. The mobile application flow is as follows: A User asks for a favour The user can choose to; notify all friends, notify favourite friends or notifdy closeby friends Depending on what the user chose, people are notified What is the best way to do

What's the proper way to store this data in a MySQL schema?

强颜欢笑 提交于 2019-12-04 03:55:12
I have a movie in a MySQL database. A movie contains data attributes that will never change, such as the following: Barcode: 025192018626 Format: DVD Runtime: 121 min. Discs: 1 Title: 12 Monkeys Year: 1995 It's one single row in a table. But I want to give my user's complete customization over this information in case something is incorrect according to them or if they just want to modify how the data is displayed in some way. I don't care why, I just want to give my users an option to do what they want. Let's say User #1 wants to change the Title for them to be "12 Monkeys (Shelf 1)" and that

Break atomicity rule storing list of items when there is no reason to query about items? Verses join table that requires whole join table be scanned

杀马特。学长 韩版系。学妹 提交于 2019-12-04 02:35:36
问题 This specific case is regarding lists, and items. The same item may belong to multiple lists, and each list has many items. Option A (the "proper" way as I understand it): Make a join table, which has list_ID and item_ID. When I want all the items in a list query for list_ID. Option B (break the atomicity rule): Make a list table. Primary Key, and either repeating columns or non-atomic columns. As I understand it both of these deviations suffer the exact same drawbacks, which is the inability