database-design

MySQL - Should I use multi-column primary keys on every child table?

随声附和 提交于 2019-12-23 04:28:27
问题 Setup: I was trying to understand the difference between identifying and non-identifying relationships when I found this great article on stackexchange. What's the difference between identifying and non-identifying relationships? After reading a few comments it brought another question to mind about a problem I have been having. Question: Should I use multi-column primary keys on every child table and what are the advantages/disadvantages to doing so? To better illustrate my question I have

Modelling Many Rails Associations

不羁岁月 提交于 2019-12-23 04:26:42
问题 I'm trying to wrap my head around how I should model my database for a parent model with many has_one associations (20+). I have one model called House which is the parent model of all the other models: class House < ActiveRecord::Base has_one :kitchen has_one :basement has_one :garage has_one :common_room #... Many other child models end All the child models contain unique properties specific to their own class. I've thought about STI, but there isn't really any shared functionality or

Tags architecture

一曲冷凌霜 提交于 2019-12-23 04:20:37
问题 I am building a multi-site platform, similar to StackExchange in the way that it has several communities using the same platform and sharing data. Users can "tag" their content the same way you can tag a stack exchange question. What is the best architecture to create a tag concept? Some small notes I thought about was the concept of aliases (synonyms). Also I thought on one hand I want tags to be shared across sites (so one can see content from another site on the same topic), but on the

Database scheme design social networking sites

非 Y 不嫁゛ 提交于 2019-12-23 04:19:29
问题 Hi I am planning to design a social networking site (like orkut) asp.net mvc.I am stuck in database design.Anyone provide me the resource for that one. 回答1: These are the steps you should follow for initial database design. First, list down all the "objects" you want to store, such as users, posts, relationships and so on. Second, figure out, for each of those, what information you want to store (user name, password, full name, address, ...). Then design your database tables following the

properties table pattern vs storing all properties in json column [duplicate]

安稳与你 提交于 2019-12-23 04:19:09
问题 This question already has answers here : When can I save JSON or XML data in an SQL Table (8 answers) Storing JSON in database vs. having a new column for each key (10 answers) Closed 8 months ago . I'd like some feedback on having all properties a model can have in a properties table accessed via relationship (using laravel relationships) vs storing all properties/settings in the same table but in a json column. Currently, my application has a propeties table called settings that is also

How to model one-to-many relationship in database

∥☆過路亽.° 提交于 2019-12-23 03:44:35
问题 I have a database containing tables using foreign keys to indicate relationships among them. In one table I have 2 columns.. 1 is id (foreign key) and other contains friendsids (foreign key from friends table). Either I can put the friends on separate rows: | id | friendsids | | 1 | 3 | | 1 | 4 | | 1 | 5 | Or pack them into a single string field: | id | friendsids | | 1 | 3,4,5 | In second way later I will separate friendsids using PHP explode() . Also do remember I have lots of records.

Develop Database Schema for Notify like facebook

不打扰是莪最后的温柔 提交于 2019-12-23 03:40:37
问题 I want to create a simple social app to test performance of mongoDB For example I post a status "Hello every body, have a good day" my Social send notifications whenever others user "like","comments","share" "A like your post" -> create a new notify "B like your post" -> create a new notify "C comment in your post" -> new no "D comment in your post" -> new no the first time, I try to design it like this notify_post { "post_id":"", "link" : "",//link to post "type": ""//like comment or share

Cross-referencing foreign keys in Django 1.4

◇◆丶佛笑我妖孽 提交于 2019-12-23 03:37:08
问题 I have a Django project where I would need two models to have a foreign key to each other. However this is not possible because two Python files would have to import each other which Python doesn't allow. What is the best way to solve this problem? So my code currently looks like this: countries/models.py: from django.db.models import Model, ForeignKey from users.models import Profile class Country(Model): president = ForeignKey(Profile) users/models.py: from django.db.models import Model,

Doctrine: tracking history of slowly changing dimensions

南笙酒味 提交于 2019-12-23 03:36:29
问题 I'm developing a type of web shop in Symfony3/Doctrine. In order to simplify things, let's say I have a table Repairs and one Parts . Parts have a name and a price, and a Repair can use many Parts, as well as various Parts can be used in various Repairs (Many-to-many). The price of a Repair is the sum of the prices of the Parts and some other factors. Slowly changing dimensions Now it should be possible to change the price of one Part , and this should change the price of future Repairs .

How can you reference multiple rows in another table?

百般思念 提交于 2019-12-23 03:14:37
问题 Let's suppose I have a table of roles, for example, Roles ----- ID Name 0 Salesman 1 Client 2 Manager Let's also suppose that these roles are not mutually exclusive: that is, a person can be a salesman, a client, and a manager all at the same time. If I have a Person table with a Role field, how am I able to reference multiple rows in the Roles table? 回答1: You introduce a new table that references both of the original tables: CREATE TABLE PersonRoles ( PersonID int not null, RoleID int not