database-design

How to guarantee uniqueness when N tables have 1:1 relationship with a common table?

自闭症网瘾萝莉.ら 提交于 2020-01-01 18:57:13
问题 Lets suppose I have a scenario with the following model: An Animal table which represents any animal, a Dog table and a Bird table, each one with a 1:1 relationship with the Animal table. Animal INTEGER id (PK) STRING name Bird INTEGER id (PK FK referencing `Animal.id`) Dog INTEGER id (PK FK referencing `Animal.id`) (I'm giving only the keys just to be clear) How can I guarantee that a given row in the Animal table will have JUST one referenced row in either the Dog or the Bird table? The

Database design - Similar Contact Information for multiple entities

孤者浪人 提交于 2020-01-01 16:59:31
问题 I realise that the answer to these types of questions are often "it depends" but still I wondering what the general consensus might be. I am dealing with multiple entities such as Company Charity Auditor Stocktaker etc etc... Which all have contact information such as e-mail, telephone and address. The two design methods I was thinking to store the contact info were Method 1) create role tables between the contact tables and company, charity, auditor and stocktaker. dbo.Company -> dbo

Database design - Similar Contact Information for multiple entities

白昼怎懂夜的黑 提交于 2020-01-01 16:58:32
问题 I realise that the answer to these types of questions are often "it depends" but still I wondering what the general consensus might be. I am dealing with multiple entities such as Company Charity Auditor Stocktaker etc etc... Which all have contact information such as e-mail, telephone and address. The two design methods I was thinking to store the contact info were Method 1) create role tables between the contact tables and company, charity, auditor and stocktaker. dbo.Company -> dbo

Entity Framework - how to manage tables in different databases but on the same server?

◇◆丶佛笑我妖孽 提交于 2020-01-01 16:25:08
问题 I am using SQL Server 2008. It seems as though in EF I need a different entity context for each database. Joining tables between databases means having to allow for this which is inconvenient and makes it more likely that I would simply put everything in one database. Am I missing something? Surely EF can work better than this? 回答1: You could map your entities to a view that returns joined tables, so your EF model doesn't know about all this technical DB stuff. 回答2: I don't think it's

Database “supertable” vs more tables vs generic table

寵の児 提交于 2020-01-01 13:35:48
问题 I'm trying to decide on a database design. More specifically, this is a sub-part of a larger design. Basically, there are "Locations" - each location can have any number of sensors associated with it, and it can have a logger (but only 1). I have sensor readings and I have logger readings, each different enough I think to warrant separate tables. If a sensor reading goes out of range, an alert is generated. While a sensor reading stays out of range, they keep being associated with that alert

HBase: Create multiple tables or single table with many columns?

ε祈祈猫儿з 提交于 2020-01-01 11:00:10
问题 When does it make sense to create multiple tables as opposed to a single table with a large number of columns. I understand that typically tables have only a few column families (1-2) and that each column family can support 1000+ columns. When does it make sense to create separate tables when HBase seems to perform well with a potentially large number of columns within a single table? 回答1: Before answering the question itself, let me first state some of the major factors that come into play.

Relational to NoSQL Database

懵懂的女人 提交于 2020-01-01 10:28:08
问题 This question is for all NoSQL and specially mongoDB experts out there. I started by designing a relational DB for a project but client wants us to use a DB that can easily scale. To achieve this we have decided to use mongoDB. These days I am having trouble mapping my relational model for NoSQL. I have a users table which has a many-to-many relation with a lot of other tables as illustrated below: I have a few options when converting it for mongoDB: Option 1 (with complete rows in users):

Indexing & alternatives for low-selectivity columns

你说的曾经没有我的故事 提交于 2020-01-01 09:13:25
问题 What are the range of tactics available for selecting records on low selectivity columns? An example might be an orders table where, over many years, you build up a large number of completed orders but often need to select active orders. An order might go through a lifecycle such as placed, stock-allocated, picked from warehouse, despatched to customer, invoiced and paid. An order might additionally be cancelled, held, etc. The majority of records will eventually be in the final state (e.g.

Indexing & alternatives for low-selectivity columns

僤鯓⒐⒋嵵緔 提交于 2020-01-01 09:13:02
问题 What are the range of tactics available for selecting records on low selectivity columns? An example might be an orders table where, over many years, you build up a large number of completed orders but often need to select active orders. An order might go through a lifecycle such as placed, stock-allocated, picked from warehouse, despatched to customer, invoiced and paid. An order might additionally be cancelled, held, etc. The majority of records will eventually be in the final state (e.g.

How to make a composite key to be unique?

。_饼干妹妹 提交于 2020-01-01 09:11:31
问题 I am making a database of students in one school.Here is what I have so far: If you don't like reading jump to the "In short" part The problem is that I'm not happy with this design. I want the combination of grade , subgrade and id_class to be unique and to serve as a primary key for the students table. I can remove the student_id and make a composite key from the 3 but I don't want that either. Maybe I should make another table lets say combination_id where grade , subgrade and id_class are