relational-database

Foreign Key Referencing Multiple Tables

◇◆丶佛笑我妖孽 提交于 2019-11-29 08:37:54
I have a column with a uniqueidentifier that can potentially reference one of four different tables. I have seen this done in two ways, but both seem like bad practice. First, I've seen a single ObjectID column without explicitly declaring it as a foreign key to a specific table. Then you can just shove any uniqueidentifier you want in it. This means you could potentially insert IDs from tables that are not part of the 4 tables I wanted. Second, because the data can come from four different tables, I've also seen people make 4 different foreign keys. And in doing so, the system relies on ONE

Strategic issue: Mixing relational and non-relational db?

前提是你 提交于 2019-11-29 07:04:47
问题 There has been a lot of talk about contra-revolutionary NoSQL databases like Cassandra, CouchDB, Hypertable, MongoDB, Project Voldemort, BigTable, and so many more. As far as I am concerned, the strongest pros are scalability, performance and simplicity. I am seriously considering to suggest using some non-relational db for our next project. However, some teams comprise some RDBMS fanatics, so convincing a hard switch might be impossible in some cases just because of emotional reasons. Also,

Adding constraints in phpMyAdmin

别等时光非礼了梦想. 提交于 2019-11-29 05:39:17
I feel like I'm being stupid, but I can't find anywhere on the phpMyAdmin interface to add constraints to foreign keys e.g. CASCADE ON DELETE I've looked for similar questions on here and on the phpMyAdmin wiki but I can't find anything about it. I realise I could do this via the query interface, but I'd like to know how to do it through the graphical interface. First, you should have your storage engine as InnoDB. Then select a table and go to 'Structure' tab. Under the table you will see 'Relation view', click it. From there you could add constraints. CASCADE Whenever rows in the master

How to query graph/hierarchical data in mysql

巧了我就是萌 提交于 2019-11-29 05:20:00
Suppose I have a table of objects structured in a hierarchy: A |--B |--C | +--D +--E They are stored in a "parent-child" table thus: parent child A B A C C D A E How do I query this to get the structure defined above? I think I need something that produces info like this: object full_path A NULL B A C A D A.C E A I cannot figure out how to do the objects nested more than one level deep. It feels like I might need to iterate over the table (no idea if this is possible in SQL), or otherwise use some kind of query I've never encountered before. Additional Info: A need not be the only orphan

how are viewing permissions usually implemented in a relational database?

旧街凉风 提交于 2019-11-29 04:54:05
What's the standard relational database idiom for setting permissions for items? Answers should be general; however, they should be able to be applied to example below. Anything flies: adding columns, adding another table—whatever as long as it works well. Application / Example Assume the Twitter database is extremely simple: we have one User table, which contains a login and user id; we have a Tweet table, which contains a tweet id, tweet text, and creator id; and we have a Follower table, which contains the id of the person being followed and the follower. Now, assume Twitter wants to enable

Hierarchical Data - Nested Set Model: MySql

人盡茶涼 提交于 2019-11-29 04:31:16
I am just learning how to implement the Nested Set Model but still have confusion with a certain aspect of it involving items that may be part of multiple categories. Given the example below that was pulled from HERE and mirrors many other examples I have come across... How do you avoid duplication in the DB when you add Apples since they are multi-colored (i.e. Red, Yellow, Green)? Lachezar Balev You do not avoid duplications and the apple (or a reference to the apple) will be placed twice in your tree otherwise it won't be a tree but rather a graph. Your question is equally applicable if you

Will this (normalised) database structure permit me to search by tags as I intend?

一曲冷凌霜 提交于 2019-11-29 04:16:14
I am trying to set up a normalised MySQL database containing the three following tables. The first table contains a list of items which can be described by various tags. The third table contains the various tags used to describe the items in the first table. The middle table relates the other two tables to each other. In each table's case, the id is an auto-incrementing primary key (and each is used as the foreign key in the middle table) +---------------+---------------------+---------------+ | Table 1 | Table 2 | Table 3 | +---------------+---------------------+---------------+ |id item |id

Data migration between different DBMS's

给你一囗甜甜゛ 提交于 2019-11-29 04:10:38
问题 As i couldnt get any satisfying answer to my Question it seems we have to write our own program for that, we are in the design phase and we are thinking which format shall we use to backup the data. The program will be written in Delphi. Needed is Exporting/Importing data between Oracle/Informix/Msserver, very important here is the Performance issue, as this program will run on a 1-2 GB Databases. Beside the normal data there are Blobs in the Database which have to be backuped. We thought of

Look-up vs relationship Microsoft Access

我只是一个虾纸丫 提交于 2019-11-29 02:31:06
I'm developing a Microsoft Access 2013 based information system. One of the client's demands was to simplify the data entry process by using combo box with available values. For example, instead of entering agentID the client asked to let the user choose agent name from the combo box, the same logic with other similar fields. In brief: I need to avoid as much as possible the need to enter the values ID and let to user choose them from the combo box. Microsoft Access has a built-in lookup wizard that allows to user to bind the table field with specific field from another table, e.g. to link

natural key vs surrogate key an innodb foreign key

你离开我真会死。 提交于 2019-11-29 01:43:00
A question: I have 2 tables: Product id INT name VARCHAR(64) something TEXT else INT entirely BOOL and Ingredient id INT name VARCHAR(64) description TEXT Now I also have a link table Products_Ingredients product_id INT ingredient_id INT for my many to many relation. Now both products and ingredients will have unique names. So I can use names as natural keys... however will that be a good idea? Say I have a product: Paint Thinner Supreme with ingredient: Butylonitrotetrocycline Will that be a good idea to use those names as composite key in the link table? As much as I understand idea behind