relational-database

How to implement total disjoint specialization in database?

左心房为你撑大大i 提交于 2019-12-18 05:22:28
问题 Say there is a database for students and professors (a very simple one) and the relational database is the following: GradStudent (_id_, name, gradStuff) UndergradStudent (_id_, name, underGradStuff) Professor (_id_, name) Teaches(_prof_id_, _stud_id_) Considering that the relational database above is meant to represent total disjoint specialization, i.e. there is no table Student but rather two completely seperate ones, when writing this in SQL in order to implement the database, how would I

Best way to create nested array from tables: multiple queries/loops VS single query/loop style

守給你的承諾、 提交于 2019-12-18 05:03:48
问题 Say I have 2 tables, which I can "merge" and represent in a single nested array. I'm wandering what would be the best way to do that, considering: efficiency best-practice DB/server-side usage trade-off what you should do in real life same case for 3, 4 or more tables that can be "merged" that way The question is about ANY server-side/relational-db. 2 simple ways I was thinking about (if you have others, please suggest! notice I'm asking for a simple SERVER-SIDE and RELATIONAL-DB , so please

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

跟風遠走 提交于 2019-12-18 04:12:23
问题 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) +---------------+---------------------+---------------

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

Deadly 提交于 2019-12-18 04:12:07
问题 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) +---------------+---------------------+---------------

Difference between one-to-many and many-to-one relationship

大城市里の小女人 提交于 2019-12-17 23:19:20
问题 What is the real difference between one-to-many and many-to-one relationship? It is only reversed, kind of? I can't find any 'good-and-easy-to-understand' tutorial about this topic other than this one: SQL for Beginners: Part 3 - Database Relationships 回答1: Yes, it a vice versa. It depends on which side of the relationship the entity is present on. For example, if one department can employ for several employees then, department to employee is a one to many relationship (1 department employs

What is the difference between 3NF and BCNF?

岁酱吖の 提交于 2019-12-17 21:43:11
问题 Can someone please explain the difference between 3NF and BCNF to me? It would be great if you could also provide some examples. Thanks. 回答1: The difference between 3NF and BCNF is subtle. 3NF Definition A relation is in 3NF if it is in 2NF and no non-prime attribute transitively depends on the primary key. In other words, a relation R is in 3NF if for each functional dependency X ⟶ A in R, at least one of the following conditions are met: X is a key or superkey in R A is a prime attribute in

retrieve correct data from my schemas

落爺英雄遲暮 提交于 2019-12-17 16:41:53
问题 I would like to retrieve the Names of teachers who teach more than 1 course I am really stuck on how to do it , all I know is that I need to consider the Course schema and operate on it , could I get some advice in terms of pi(projection),sigma(condition),rho(rename) etc (not i any specific database language)? 回答1: Since this is homework and you basically need to read & work through a textbook's absolutely introductory text & exercises on relational model basics & the relational algebra, I

Do stored procedures run in database transaction in Postgres?

好久不见. 提交于 2019-12-17 16:28:24
问题 If a stored procedure fails in middle, are changes at that point from the beginning of SP rolled back implicitly or do we have to write any explicit code to make sure that SP runs in a database transaction only? 回答1: Strictly speaking, Postgres did not have stored procedures as defined in the ISO/IEC standard before version 11. The term is often used incorrectly to refer to functions , which provide much of the same functionality (and more) as other RDBMS provide with "stored procedures". The

Database design for user settings

时光总嘲笑我的痴心妄想 提交于 2019-12-17 10:18:07
问题 Which of the following options, if any, is considered best practice when designing a table used to store user settings? (OPTION 1) USER_SETTINGS -Id -Code (example "Email_LimitMax") -Value (example "5") -UserId (OPTION 2) create a new table for each setting where, for example, notification settings would require you to create: "USER_ALERT_SETTINGS" -Id -UserId -EmailAdded (i.e true) -EmailRemoved -PasswordChanged ... ... "USER_EMAIL_SETTINGS" -Id -UserId -EmailLimitMax .... (OPTION 3) "USER"

Comparison of Relational Databases and Graph Databases

南笙酒味 提交于 2019-12-17 10:11:58
问题 Can someone explain to me the advantages and disadvantages for a relation database such as MySQL compared to a graph database such as Neo4j? In SQL you have multiple tables with various ids linking them. Then you have to join to connect the tables. From the perspective of a newbie why would you design the database to require a join rather than having the connections explicit as edges from the start as with a graph database. Conceptually it would make no sense to a newbie. Presumably there is