relational-database

ASP.NET MVC Entity Framework code-first: no errors but tables aren't populated correctly

*爱你&永不变心* 提交于 2019-12-12 02:54:15
问题 I'm currently making a ticketing system using MVC4 Entity Framework. I've populated my tables in my SQL server but there's only a few columns that aren't correct. Firstly I want to apologise for the amount of code but they are all needed for referencing! I only want people to check if I'm mapping my model properly because in image(1) some values are missing. It is very important that you look at the two images provided below for a clearer picture as to what I'm trying to accomplish. The image

Complicated relationships vs simple tables Entity Framework CodeFirst

感情迁移 提交于 2019-12-12 02:49:39
问题 Database design question :) Is it smarter to make a lot of interconnected tables (normalize) or is it smarter to duplicate data so queries are simpler? Here is my situation: public class TransferRequest { [Key] public int TransferRequestId { get; set; } public int By { get; set; } public int? For { get; set; } public int PersonId { get; set; } public virtual Person Person { get; set; } [ForeignKey("Transfer")] public int? ExistingTransferId { get; set; } public virtual Transfer

How to set 1 to 0…1 relationship in SQL Server Management Studio

╄→尐↘猪︶ㄣ 提交于 2019-12-12 02:49:06
问题 I have tables: Users{UserId ...} Professors{UserId ...} I set UserId to be PK in both tables and made 1:1 relationship. But if I try to insert new user it doesn't work as it requires insert in the Professor table too. I want to make that one user can have only 1 record in Professor table but I also want to make it that it doesn't have to exist in Professor table (I don't want to make all users professors :) ). How to set 1 to (0...1) relationship in SQL Server Management Studio? I know that

What is the best practice for changing status of a record in database

送分小仙女□ 提交于 2019-12-12 02:42:17
问题 My application is something like order tracking application. An order is saved in a order table for 300 items. If we process whole items from 1st step then I can place a field of status telling that this order is in 1st step to track the orders and make them available for next steps. But If machine of step one has capacity of processing 150 items only then I have to mention that 150 items of that order are in step 2 and 150 items are in step 1. And for this I am planning to have tables of

How to add meta data to every cell in all tables of a relational database?

[亡魂溺海] 提交于 2019-12-11 23:21:33
问题 I have a relational database (I am using SQL Server 2008) with scores of tables. I need to capture a lot of meta data for each cell (not just the row) in every table. Thankfully, the metadata schema is expected to be consistent across all tables. Further, the metadata should be queryable as well. I did not some across any such direct support built in. What is the best possible approach? 回答1: You may want to look into using SQL Server's extended properties. 来源: https://stackoverflow.com

MySQL multiple Inner Join with Where clause

别说谁变了你拦得住时间么 提交于 2019-12-11 23:15:47
问题 i have a little problem with mysql. query is follow: SELECT u.user_id,u.gender, ua.age,u.name,u.isonline,dot.profile_image_no FROM user_table AS u INNER JOIN user_answers_table AS ua ON u.user_id = ua.user_id INNER JOIN data_one_table AS dot ON dot.user_id = u.user_id INNER JOIN user_detail_table AS udt ON udt.user_id = u.user_id WHERE u.isregistrationcomplete='1' AND u.isactive='1' AND u.gender = '0' AND ua.age >= '20' AND ua.age <= '24' AND udt.lookingfor = '1' OR udt.lookingfor = '3'; i

sum totals utilization for each hour in day for all day in month

若如初见. 提交于 2019-12-11 23:09:02
问题 I have the following SQL query using PrestoDB: SELECT date_trunc('month',TimeFrom) AS Month, date_trunc('hour',TimeFrom) AS HourFrom, date_trunc('hour',TimeTo) AS HourTo, CASE WHEN resource = 'c81d9eb67e93' THEN 'S' WHEN resource = 'cce1eee4c73f' THEN 'L' WHEN resource = 'fbc1d63e0f15' THEN 'G' WHEN resource = '5ef75e433db2' THEN 'Q' WHEN resource = '4b6ba65cbe14' THEN 'T' WHEN resource = 'df0a8b60467d' THEN 'R' WHEN resource = '013472b63651' THEN 'C' WHEN resource = '7464b77d93be' THEN 'F'

Subset of a candidate key

廉价感情. 提交于 2019-12-11 22:40:58
问题 As we know a candidate key is a column or combination of columns that uniquely identifies the rows in a relation. Suppose I have a relation in which candidate keys are combinations of columns. I want to ask, is it possible that a subset of a candidate key also uniquely identifies the row? OR is a candidate key a key for which there is no subset that uniquely identifies the row? 回答1: A candidate key is a column or combination of columns. Or more correctly a set of one or more columns. Or more

Is a candidate key determinant good enough for BCNF?

半城伤御伤魂 提交于 2019-12-11 20:06:43
问题 A question that came up in my homework is as follows: If a determinant is part of a candidate key, is that good enough for BCNF? I don't think so, because a relation is in BCNF if all non-key attributes depend on the whole primary key, and nothing else. This says the determinant is part of a candidate key, so does this imply a partial functional dependency? However, I began to second guess myself because there's a possibility that the candidate key is a super key, but it doesn't seem like

Rails 4: new instance is created and saved to database but not displayed in view

帅比萌擦擦* 提交于 2019-12-11 19:38:30
问题 In our Rails 4 app, there are four models: class User < ActiveRecord::Base has_many :administrations, dependent: :destroy has_many :calendars, through: :administrations end class Administration < ActiveRecord::Base belongs_to :user belongs_to :calendar end class Calendar < ActiveRecord::Base has_many :administrations, dependent: :destroy has_many :users, through: :administrations end class Post < ActiveRecord::Base belongs_to :calendar end Here are the corresponding migrations: class