relational-database

Entity Framework inserting child objects in the wrong order

我与影子孤独终老i 提交于 2019-12-21 04:17:15
问题 Question Why is EF first inserting a child object (PersonnelWorkRecord) with a dependency, before the object that it is depended on (TimesheetActivity). Also what are my options on correcting this? ERD (simplified) This is predefined by another system out of my direct control. EF setup and save code I am not sure I understand why/how Entity Framework is inserting the objects I have in the order it does however here is the code I am using to insert a parent and several children. using (var db

Database design - Multiple “Contact information” for different tables

依然范特西╮ 提交于 2019-12-20 22:01:28
问题 I have a database with tables "person", "company", "shop", etc. Many of these tables must have "contact information". The possibility to design this was asked in Database design - Similar Contact Information for multiple entities Now, in my database I leave a possibility to have a multiple addresses, multiple phones and multiple emails to each contact data . This is my database schema: So, I make an intermediate table "contact" as a simplest way to link a "contact information" to each table.

How to empty my destination table before inserting new records in SSIS?

二次信任 提交于 2019-12-20 17:47:13
问题 I use SSIS to generate and transform new data for later use in a new system. I have a problem every time I run my SSIS Package, it keeps inserting new records to my destination tables. How can I empty my destination table (/OLE DB Destination) first and then inserting the newly generated records? Currently the workaround for this problem is performing a delete from DestTable before running my package. 回答1: Put your delete statement in an Execute SQL Task . Then make it the first component of

How should I store user “favorites” in mySQL table?

时光总嘲笑我的痴心妄想 提交于 2019-12-20 16:42:37
问题 I keep reading that I should store this in a separate table "with one value per line". What does this mean exactly? Like this - So that each "favoriting" gets another user entry? USER_ID SKU_Favorited 001 10016 001 10067 024 10016 001 10010 024 16779 Seems redundant to have to enter the same user twice, but is this what I should do? Then in lookup I just SELECT sku WHERE user id... and find all SKUs next to that number? 回答1: It is called relational databases that are in 3-rd normal form You

Using SUM with multiple joins in mysql

夙愿已清 提交于 2019-12-20 11:07:14
问题 I've been looking for a solution to this, there's plenty of similar questions but none have any proper answers that helped me solve the problem. First up, my questions/problem: I want to sum and count certain columns in a multiple join query Is it not possible with multiple joins? Do I have to nest SELECT queries? Here's a SQL dump of my database with sample data: http://pastie.org/private/vq7qkfer5mwyraudb5dh0a This is the query I thought would do the trick: SELECT firstname, lastname, sum

Query the contents of stored procedures on SQL Server

☆樱花仙子☆ 提交于 2019-12-20 11:05:57
问题 I am exploring a legacy database system and have very little knowledge of its internals. I would like to find all the stored procedures that invoke another stored procedure A . How best to do this? Can I write something like this pseudocode: select name from AllStoredProcedures as Asp where Asp.TextualContent contains 'A' Asp.TextualContent means the actual SQL contained in the SP. 回答1: SELECT OBJECT_NAME(OBJECT_ID), definition FROM sys.sql_modules WHERE objectproperty(OBJECT_ID, 'IsProcedure

How to get foreign key values with getattr from models

吃可爱长大的小学妹 提交于 2019-12-20 10:43:51
问题 i have a model Project and i am getting the attributes of that with the following instr attr = getattr(project, 'id', None) project is the instance, id is the field and None is the default return type. my question is what if i want to get the F.K keys with this? Get customer name project.customer.name How to get customer name with the above condition? Already Tried if callable(attr): context[node][field] = '%s' % attr() Current Code context = {'project': {}} fields = ('id', 'name', 'category'

Is MongoDB a valid alternative to relational db + lucene?

ぃ、小莉子 提交于 2019-12-20 08:38:42
问题 On a new project I need a hard use of lucene for a searcher implementation. This searcher will be a very important (and big) piece of the project. Is valid or convenient replacing Relational Database + Lucene with MongoDb? edit: Ok, I will clarify: I'm not asking about risk, I can pay that price in this project. My point is: Is MongoDB oriented to this kind of thing? Can I make a full search engine with the same perfomance as I can get on Lucene?. A friend point me out MongoDB as alternative,

What is the difference between a candidate key and a primary key?

吃可爱长大的小学妹 提交于 2019-12-20 08:33:56
问题 Is it that a primary key is the selected candidate key chosen for a given table? 回答1: Candidate Key – A Candidate Key can be any column or a combination of columns that can qualify as unique key in database . There can be multiple Candidate Keys in one table. Each Candidate Key can qualify as Primary Key. Primary Key – A Primary Key is a column or a combination of columns that uniquely identify a record . Only one Candidate Key can be Primary Key. More on this link with example 回答2: John Woo

MySQL best approach for db normalising, relationships and foreign keys

痴心易碎 提交于 2019-12-20 06:24:49
问题 There is an username/password verification step first then the database has following structure ^ is primary key * uses foreign key 1.StudentDetails table =========================================================================== ID^| Username | Password | Email | Address * | Website |Comments ====+============+==========+=============+===========+=========+========== 1 | xxxxxxxxxx | xxxxxxx | xx@xxx.xxx | 1 | http:// | text 2.Submissions table ==============================================