database-design

SQL update on duplicate key update

二次信任 提交于 2019-12-24 13:15:25
问题 I have asked this question Grouping and update large database table, but I didn't get the answer for this. I have a table: name, date, detail, no , and name, date, detail are together as PK. Somehow I need to update detail , and it is possible that there are duplicate key. Thus I need to sum the no for the duplicate rows. ON DUPLICATE KEY UPDATE is only used for INSERT . So how to address this problem? 回答1: First things first, that multi-column primary key is probably a bad idea; as you've

Is Reservation System Suitable for Amazon DynamoDB / NoSQL?

北战南征 提交于 2019-12-24 12:18:05
问题 I'm working on basic restaurant reservation system and was thinking about using Amazon DynamoDB for this project. That being said, I'm not even sure if DynamoDB is suitable for something like this or if I should stick to MySQL RDS since some of the queries may be quite complex. Functionality I need: User will submit a " Find Table " form with date, time and party size. Check RESTAURANT table if date and party size is even allowed. Check BLOCKED table for blocked dates (holidays and other

Database Design , Items in Category, Sub Category & Theme

拟墨画扇 提交于 2019-12-24 12:13:07
问题 CREATE TABLE Product (ProductID int, Description nvarchar(100)) CREATE TABLE CategoryID (CategoryID int, Description nvarchar(100),ProductID int) CREATE TABLE SubCategoryID (SubCategoryID int, CategoryID int, Description nvarchar(100),ProductID int) CREATE TABLE ThemeID (ThemeID int, Description nvarchar(100),ProductID int) I'm using Laravel ORM Product hasMany-> Category Product hasMany-> SubCategory Product hasMany-> Theme Category BelongsTo->Product SubCategory BelongsTo->Category Theme

SQL music playlist database design

家住魔仙堡 提交于 2019-12-24 12:04:01
问题 I had a question about how to structure my tables for a database with songs and playlists. My initial thought was to create a table of playlists titles and id's and then a playlists songs table that holds the songs unique id and the playlist in which it belongs to. The other plan was to create a new table for each playlist that gets created and store the song information inside each table for the playlist. The question is, would this be a good approach or is there some reason that creating

Returning the current project status (i.e., most recent date on Django ManyToMany relationship)

对着背影说爱祢 提交于 2019-12-24 11:54:01
问题 Schema Description A project's status can change over time. In order to track the status over time, I've created a many-to-many relationship between the Project model and the ProjectStatusType model through the ProjectStatus intermediary table. While this allows tracking a project's status over time, it increases the complexity of the schema such that retrieving the current status of a project or retrieving all open projects is more difficult. Use Case I want to be able to return all projects

What are the helpful cases of Internals Viewer for SQL Server to convince me to use it?

末鹿安然 提交于 2019-12-24 11:47:56
问题 I am in doubt whether I should spend time for installing, studying and using "Internals Viewer for SQL Server" What are the most helpful practical uses to convince me to use it for SQL Server perforamnce tuning, troubleshooting or database design? 回答1: The feature list is on the link you gave. Allocation Map Displays the physical layout of tables and indexes Displays PFS status Overlay pages in the Buffer Pool Page Viewer Displays Data pages including forwarding records and sparse columns

How to combine rows of 2 tables having some columns same and some different

陌路散爱 提交于 2019-12-24 11:42:11
问题 I have two tables for user posts, one for text post and one for multimedia post, the structure of both tables is as follows. table text_post +--------+--------------+-----------+-----------+-----------------+-----------+ | postid | post_content | post_user | post_type | post_visibility | post_date | +--------+--------------+-----------+-----------+-----------------+-----------+ table multimedia_post +-------+------------+--------+---------+---------+---------------+---------+ |post_id|post

GUID type in database

狂风中的少年 提交于 2019-12-24 11:40:12
问题 GUID is not an official data type in database. In our existing SQL Server design, the Uniqueidentifier type is used for GUID value. Now we are switching to Sybase database. Should we use varchar(36) to replace that Uniqueidentifier type? I am still confused by GUID . I was told GUID is 16 bytes long but its character string is 36 characters in length. I must missed something. 回答1: A GUID is actually an integer type - it's a 128 bit integer (16 bytes). It's often represented as a string of 36

Race condition using Postgres hstore

我是研究僧i 提交于 2019-12-24 11:37:46
问题 I have a table which has amongst many other fields one hstore db/schema.rb create_table "requests", force: true do |t| t.hstore "parameters" end Some of the records have a field parameters["company_id"] but not all of them. What I need to do is to make sure that only one Request object is created with a given parameters["company_id"] . There might be multiple attempts trying to save a record at the same time - thus the race condition. I am looking for unique company_id values inside the

Trouble handling generic relationship in django

一笑奈何 提交于 2019-12-24 11:12:51
问题 I want to model a situation and I´m having real trouble handling it. The domain is like this: There are Posts, and every post has to be associated one to one with a MediaContent. MediaContent can be a picture or a video (for now, maybe music later). So, what I have is: mediacontents/models.py class MediaContent(models.Model): uploader = models.ForeignKey(User) title = models.CharField(max_length=100) created = models.DateTimeField(auto_now_add=True) def draw_item(self): pass class Meta: