relational-database

What are the common issues surrounding storage of XML data in a relational databases?

风流意气都作罢 提交于 2019-12-05 16:05:22
In relation to a discussion started at this question , I've decided to put this up as a community wiki question. The root of the question is, therefore, is it appropriate to store XML data in a relational database? Are there generally better ways to implement the same goal? What database engines provide good support for XML data types (such as SQL Server), and what are the issues surrounding so-called "XML indexes"? Databases are for storing data. XML is data. Therefore, under the right circumstances it's perfectly valid to store XML in a database. Whether that's the most efficient thing to do

Yii2 how to check if two models are already linked

試著忘記壹切 提交于 2019-12-05 15:14:40
I have two models related through a junction table. $model->link() is the method used to establish the relationship between the two models. It basically populates the junction table with the corresponding keys of both models. If two models are linked and I try to link them again, there will be an error because the key pair already exists in the junction table. Then I'd need to check if this relation exists before attempting to link the models. I think I could just create a model for the junction table and query for the proper record. The result of that query would tell if I need to perform the

Reasons for cascading soft deletes [closed]

眉间皱痕 提交于 2019-12-05 12:15:46
In a relational database it seems quite common to use soft-deletes. My pondering comes to if it is really necessary to cascade these deletes? The reason I wonder is that it seems to me that cascading a soft delete wouldn't add any additional information. I.e. lets say we have a table MainContract and a table ServiceContract where the relation is one-to-many. Say we soft-delete the MainContract but ignore doing so to lets say three ServiceContracts that all belong to this MainContract. If we query the DB for ServiceContracts that are not deleted, we could easily check if the MainContract owning

How to model a relational database into a neo4j graph database?

早过忘川 提交于 2019-12-05 11:10:06
I have a relational database (about 30 tables) and I would like to transpose it in a neo4j graph database, and I don't know where to start... Is there a general way to transpose tables and/or tuples into a graph model ? (relations properties, one or more graphs ?) What are the best sources of documentation ? Thanks for any help, Best regards First, if at all possible, I'd suggest NOT using your relational DB as your "reference" for transposing to a graph model. All too often, mistakes and pitfalls from relational modelling get transferred over to the graph model and introduce other oddities.

mysql one-to-many query with negation and/or multiple criteria

和自甴很熟 提交于 2019-12-05 10:50:27
I thought a query like this would be pretty easy because of the nature of relational databases but it seems to be giving me a fit. I also searched around but found nothing that really helped. Here's the situation: Let's say I have a simple relationship for products and product tags. This is a one-to-many relationship, so we could have the following: productid | tag ======================== 1 | Car 1 | Black 1 | Ford 2 | Car 2 | Red 2 | Ford 3 | Car 3 | Black 3 | Lexus 4 | Motorcycle 4 | Black 5 | Skateboard 5 | Black 6 | Skateboard 6 | Green What's the most efficient way to query for all (Ford

Multiple toMany relationships to a single table

给你一囗甜甜゛ 提交于 2019-12-05 10:28:14
I'm new to greenDAO and I'm working on writing the DaoGenerator. One issue that I've run into is that I have a user table and a wallpost table. I would like to be able to have two columns in the wallpost table that are toMany relations to the user table (the wall owner and the posting user) they may or may not be the same user, but so far it doesn't look like it is possible to have two toMany relations that point to a single table in the same table. Is there a better way to do this/a way to make this possible? I'm hoping to be able to load the wall posts and fetch the wall owner and posting

PonyORM: What is the most efficient way to add new items to a pony database without knowing which items already exist?

Deadly 提交于 2019-12-05 07:57:53
Forgive me if this is an obvious question but I'm new to pony and databases in general and didn't find the right part of the documentation that answers this question. I'm trying to create a database with companies and the locations where those companies have offices. This is a many-to-many relationship since each company is in multiple locations and each location can be host to multiple companies. I'm defining my entities as such: from pony import orm class Company(db.Entity): '''A company entry in database''' name = orm.PrimaryKey(str) locations = orm.Set('Location') class Location(db.Entity)

Database Modeling: How to catogorize products like Amazon?

家住魔仙堡 提交于 2019-12-05 05:25:40
问题 Assume I had a number of products (from a few thousands to hundred of thousands) that needed to be categorized in a hierarchical manner. How would I model such a solution in a database? Would a simple parent-child table like this work: product_category - id - parent_id - category_name Then in my products table, I would just do this: product - id - product_category_id - name - description - price My concern is that this won't scale. By the way, I'm using MySQL for now. 回答1: Course it will

Does Eloquent relation sync also remove?

邮差的信 提交于 2019-12-05 05:23:04
When updating a model and I sync a relationship, if I don't pass in all the ids that already exist, will that relationship be removed? You decide: sync has 2nd parameter that defaults to true and is responsible for detaching: $model->relationship()->sync([1,2,3]); $model->relationship()->sync([4,5,6]); // attached [4,5,6], detached [1,2,3] $model->relationship()->getRelatedIds(); // [4,5,6] // but: $model->relationship()->sync([4,5,6], false); // attached [4,5,6], detached [] $model->relationship()->getRelatedIds(); // [1,2,3,4,5,6] The answer is Yes it does. I could not find any documentation

Should User and Address be in separate tables?

送分小仙女□ 提交于 2019-12-05 04:23:56
Currently my users table has the below fields Username Password Name Surname City Address Country Region TelNo MobNo Email MembershipExpiry NoOfMembers DOB Gender Blocked UserAttempts BlockTime Disabled I'm not sure if I should put the address fields in another table. I have heard that I will be breaking 3NF if I don't although I can't understand why. Can someone please explain? There are several points that are definitely not 3NF; and some questionable ones in addition: Could there could be multiple addresses per user? Is an address optional or mandatory? Does the information in City, Country