database-design

I'm storing code snippets in my database. How can I enable revisions/versions of them?

主宰稳场 提交于 2021-01-28 01:52:58
问题 I have a pretty primitive table schema now ( in Postgres ): CREATE TABLE "public"."sandbox_demo" ( "id" int4 DEFAULT nextval('sandbox_demo_id_seq'::regclass) NOT NULL, "source" text DEFAULT NULL NOT NULL, "created" timestamptz(6) DEFAULT NULL NOT NULL, "modified" timestamptz(6) DEFAULT NULL NOT NULL ) However, this table only supports plain entries and there's no parent child relationship or a mapping table so I could have revisions of the initial code snippet. What would be an ideal way of

Database design - nullable fields

倖福魔咒の 提交于 2021-01-27 21:05:57
问题 Bit of a 'best practice' question as I am new to DB design and I wanted to make sure I am on the right tracks with this one I have 3 user types, user (single person), group (lots of users) and company (lots of groups), each has their own login which allows them to post messages. So eg. if a company posts a message it will appear in all the linked users news feeds. To achieve this I have a table 'messages' that stores the message contents, along with the foreign keys to link the user types I

Localized entities in database

↘锁芯ラ 提交于 2021-01-27 19:05:52
问题 I'm developing a ASP.NET Core MVC application and need to design Multilanguage values for entities. There is a lot information how to support localization in UI pages using .resx. I'm looking for some common pattern how to support localization for entities (not for static content on web page), that can be edited by user. Let say there is a simple dictionary in database table with Statuses Id Name ---------------------------------------------- 1 Not processed 2 To be cancelled 3 To be

Which database structure to choose? [closed]

一曲冷凌霜 提交于 2021-01-27 12:52:04
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I want to implement a notification system. I have users and each user has notification setting Structure 1: Users Notification_settings Notifications -id (pk) -id -id (pk) -username -user_id (fk) references Users

Disadvantages of table with too many columns

旧时模样 提交于 2021-01-23 06:06:52
问题 I have some data that I need to put in a PostgreSQL database. These data are related to schools. So there are a LOT of attributes relating to the school, mostly small integers, floats or small texts. And all the data changes yearly. So I'm creating an entity called YearlyData and putting the attributes there. But the thing is, the number of attributes are around 50-60. Now these cannot be normalized because they are plain attributes of the school itself. So I ethically cannot separate them

Database to track user notifications or activity (Facebook like)

*爱你&永不变心* 提交于 2020-12-29 06:27:58
问题 I've just read the following posts on the same topic: Facebook like notifications tracking (DB Design) and Database design to store notifications to users Some solutions were offered but not exactly what I need and how it should be for a Facebook-like notification system. In a notification, we often have some links pointing to the user who took some action, link to a post or video he commented on, link to anything, and ofter we have several links in a single notification. notification -------

Database to track user notifications or activity (Facebook like)

那年仲夏 提交于 2020-12-29 06:27:52
问题 I've just read the following posts on the same topic: Facebook like notifications tracking (DB Design) and Database design to store notifications to users Some solutions were offered but not exactly what I need and how it should be for a Facebook-like notification system. In a notification, we often have some links pointing to the user who took some action, link to a post or video he commented on, link to anything, and ofter we have several links in a single notification. notification -------

Database indexes: A good thing, a bad thing, or a waste of time?

删除回忆录丶 提交于 2020-12-28 07:28:37
问题 Adding indexes is often suggested here as a remedy for performance problems. (I'm talking about reading & querying ONLY, we all know indexes can make writing slower). I have tried this remedy many times, over many years, both on DB2 and MSSQL, and the result were invariably disappointing. My finding has been that no matter how 'obvious' it was that an index would make things better, it turned out that the query optimiser was smarter, and my cleverly-chosen index almost always made things

Where should I store a foreign key?

半城伤御伤魂 提交于 2020-12-27 08:11:07
问题 If I have a relationship between two tables (both tables have their own primary keys) what should guide my decision as to which table should store the foreign key? I understand that the nature of the relationship probably matters (one-to-one, one-to-many, many-to-many, uni-directional, bi-directional), and probably access patterns matter too. What is a systematic way of making that decision though? 回答1: Which table is the child in the relationship? Answer that, and you know which table needs

Managing surrogate keys in a data warehouse

▼魔方 西西 提交于 2020-12-25 04:57:20
问题 I want to build a data warehouse, and I want to use surrogate keys as primary keys for my fact tables. But the problem is that in my case fact tables should be updated. The first question is how do I find a corresponding auto-generated surrogate key for the natural key in the source system? I have seen some answers mentioning lookup tables which store correspondence between natural and surrogate keys, but I didn't understand how exactly they are implemented. Where this table should be stored: