data-modeling

Best way to represent a color in a SQL Database?

╄→尐↘猪︶ㄣ 提交于 2019-12-01 01:47:23
问题 If I am using .Net and SQL Server 2008, what is the best way for me to store a color in the database, should I use ToString or convert it to an integer, or something else? Edit: All I want from the colour is to be able to retrieve it and draw something on the screen in the specified colour. I don't need to be able to query against it. 回答1: How are the colors stored natively? If you're just using 0xRRGGBB format, you may as well store it as an integer in the database, and re-hexify it when you

Database Tables, more the better?

谁说胖子不能爱 提交于 2019-12-01 00:16:23
Lately I've been rethinking a database design I made a couple of months ago. The main reason is that last night I read the databse schema of vBulletin and saw that they use many, MANY, tables. The current "idea" I'm using for my schema, for instance my log table, is to keep everything in one table by differencing the type of Log with an integer: id, type, type_id, action, message 1 , 1, 305, 2, 'Explanation for user Ban' 2, 2, 1045, 1, 'Reason for deletion of Article' Where type 1 = user, type 2 = article , type_id = the ID of the user, article or w/e and action 2 = ban, action 1 = deletion .

Database Tables, more the better?

空扰寡人 提交于 2019-11-30 18:24:57
问题 Lately I've been rethinking a database design I made a couple of months ago. The main reason is that last night I read the databse schema of vBulletin and saw that they use many, MANY, tables. The current "idea" I'm using for my schema, for instance my log table, is to keep everything in one table by differencing the type of Log with an integer: id, type, type_id, action, message 1 , 1, 305, 2, 'Explanation for user Ban' 2, 2, 1045, 1, 'Reason for deletion of Article' Where type 1 = user,

Database design - Approach for storing points for users

耗尽温柔 提交于 2019-11-30 16:26:59
Just looking for some suggestions on how to approach the database design for this. On my site a user can get points for performing different activities. Currently there are 3 activities for which I award points - but the design has to be scalable where I can add other activities for awarding points as well. So today - the user gets points 1) When he adds a new store he gets 10 points (Store information is stored in STORE table) 2) When he answers a question he gets 7 points (Questions/answers are stored in a ANSWERS table) 3) When he refers friends who join the site he gets 5 points So this is

Entity Framework multitenant shared data architecture: single column, multiple foreign keys

非 Y 不嫁゛ 提交于 2019-11-30 13:26:24
I have the following data structure: //property Notification abstract class BindableBase { } //base class for all tenant-scoped objects abstract class TenantModelBase : BindableBase { int TenantId; } abstract class Order : TenantModelBase { Customer Customer; //works: mapped using TenantId and CustomerId Product Product; //again, works with TenantId and ProductId string ProductId; string CustomerId; } class Customer: TenantModelBase { string CustomerId; } class Product : TenantModelBase { string ProductId; } class SpecialOrder : Order { OtherClass OtherClass; //this fails!, see below string

Is using char as a primary/foreign key a no no?

这一生的挚爱 提交于 2019-11-30 13:04:43
Consider that there is a bunch of tables which link to "countries" or "currencies" tables. For making data easier to read I'd like make CHAR field with country code (eg US, GB, AU) and currency code (USD, AUD) a primary keys in each of those 2 tables and all other tables will use this CHAR as a foregin key. Database is mysql with innodb engine. Is it going to cause performance issues? Is it something i should avoid? cletus Performance isn't really the main issue, at least not for me. The issue is more about surrogate vs natural keys. Country codes aren't static. They can and do change.

How to properly cascade delete managed objects in Core Data?

為{幸葍}努か 提交于 2019-11-30 11:31:37
I have a Core Data model which has three entities: A, B, and C. A has a one-to-many relationship with B, and B has a many-to-many relationship with C. The delete rule for A -> B is "Cascade", and B -> A is "No Action". The delete rule for B -> C is "No Action", and C -> B is "Deny". I am having trouble performing a delete on the A entity. What I want to happen is the following: I delete an instance of A (using deleteObject: ) The delete propagates to any B's associated with A (due to the "Cascade" delete rule) All B's associated with A are deleted Any relationships belonging to C's whose

How do I model (GitHub-like) permissions relationally?

老子叫甜甜 提交于 2019-11-30 09:13:46
tl;dr: how do i implement a permissions model like (e.g.) github's Updated to try to address some of @philipxy's comments: I am planning to implement a permissions model similar to github's: users users can be in groups users can be in organizations groups can be in organizations a user will be permitted any of C, R, U, and D operations on an asset, group, or organization as : an individual user who has been permitted those (any of C, R, U, D) operations a member of a group which has been granted those permissions a member of an organization that has been granted those permissions or as a

Best way to store a many-to-many relationship in MySQL?

£可爱£侵袭症+ 提交于 2019-11-30 07:36:02
问题 Let's say I have a simple database with tables 'posts' and 'tags'. Posts can have many tags and tags can belong to many posts. What is the best way to structure the database? I thought of using a list/serialize: tags idx tag_id, str tag_name posts idx post_id, str title, list tag_ids OR having another table with the associations. Problem is using this I don't even know how to structure the query to pull the associated tag names when I get a post. posts idx post_id, str title post_tags fk post

Managing hierarchies in SQL: MPTT/nested sets vs adjacency lists vs storing paths

旧城冷巷雨未停 提交于 2019-11-30 01:25:21
For a while now I've been wrestling with how best to handle hierarchies in SQL. Frustrated by the limitations of adjacency lists and the complexity of MPTT/nested sets, I began thinking about simply storing key paths instead, as a simple node_key/node_key/... string. I decided to compile the pros and cons of the three techniques: Number of calls required to create/delete/move a node: Adjacency = 1 MPTT = 3 Path = 1 (Replace old node path with new node path across all nodes that contain that path) Number of calls required to get a tree: Adjacency = [number of sub-levels] MPTT = 1 Path = 1