relational-database

SQL: Creating a relation table with 2 different auto_increment

。_饼干妹妹 提交于 2019-11-26 14:40:56
I have 2 tables, both with their own auto incremented IDs, which are of course primary keys. When I want to create a 3rd table to establish the relation between these 2 tables, I always have an error. First one is about that you can have only 1 automatically-incremented column, the second one occurs when I delete the auto_increment statement from those 2, therefore sql doesn't allow me to make them foreign keys, because of the type matching failure. Is there a way that I can create a relational table without losing auto increment features? Another possible (but not preffered) solution may be

NoSql vs Relational database

孤街醉人 提交于 2019-11-26 14:03:01
Recently NoSQL has gained immense popularity. What are the advantages of NoSQL over traditional RDBMS ? Not all data is relational. For those situations, NoSQL can be helpful. With that said, NoSQL stands for "Not Only SQL". It's not intended to knock SQL or supplant it. SQL has several very big advantages: Strong mathematical basis. Declarative syntax. A well-known language in Structured Query Language (SQL). Those haven't gone away. It's a mistake to think about this as an either/or argument. NoSQL is an alternative that people need to consider when it fits, that's all. Documents can be

What to do with null values when modeling and normalizing?

自古美人都是妖i 提交于 2019-11-26 13:51:11
I'm new in SQL(still learning) and I have to create a database for a venue. A client book for a room for an event. The problem is that the clients don't always provide their name, their email, and their phone number. Most of the time it's either name and email or name and phone. It's rarely all 3 but it happens. I need to store each of these in their respective attribute (name, email, phone). But the way they give me their info, I have a lot of null values. What can I do with these nulls? I've been told that it's better to not have nulls. I also need to normalize my table after that. Any

NULL permitted in Primary Key - why and in which DBMS?

有些话、适合烂在心里 提交于 2019-11-26 12:45:29
问题 Further to my question \"Why to use ´not null primary key´ in TSQL?\"... As I understood from other discussions, some RDBMS (for example SQLite, MySQL ) permit \"unique\" NULL in the primary key. Why is this allowed and how might it be useful? Background: I believe it is beneficial for communication with colleagues and database professionals to know the differences in fundamental concepts, approaches and their implementations in different DBMS. Notes MySQL is rehabilitated and returned to the

Difference between a theta join, equijoin and natural join

北城余情 提交于 2019-11-26 12:36:11
问题 I\'m having trouble understanding relational algebra when it comes to theta joins, equijoins and natural joins. Could someone please help me better understand it? If I use the = sign on a theta join is it exactly the same as just using a natural join? 回答1: A theta join allows for arbitrary comparison relationships (such as ≥). An equijoin is a theta join using the equality operator. A natural join is an equijoin on attributes that have the same name in each relationship. Additionally, a

Sql - Indirect Foreign Key

百般思念 提交于 2019-11-26 12:30:53
I have some questions about database design. Is there a name for this? Is it good practice? Any performance considerations? I have a generic table structure used to store relationships. Recently I refactored some things to use this generic structure instead of direct Fk columns, but now I'm not sure if that was really the best idea. Original Schema: +------------------+ +---------------------+ +----------------------+ | Book | | Note | | MetaParent | |------------------| |---------------------| |----------------------| | Id | | Id | | Id | | NoteId | | MetaParentId:(Null) | | MetaTableId | | +

uncertainty in developing a database model

戏子无情 提交于 2019-11-26 11:39:07
问题 I\'m trying to develop a database model for candidate, their registered exams and result of the exams when its being taken. This is what I\'ve done so far. however im unsure if am on the right track especially from the examination table to the examination result table. how easy will it be to right write an insert sql code for examinationresult population for a particular candidate the examination types are categorised into science, art and social science. they all have 4 components each 来源:

How do you like your primary keys? [closed]

会有一股神秘感。 提交于 2019-11-26 11:34:49
In a fairly animated discussion in my team I was made to think what most people like as primary keys. We had the following groups- Int/ BigInt which autoincrement are good enough primary keys. There should be at least 3 columns that make up the primary key. Id, GUID and human readable row identifiers all should be treated differently. What's the best approach for PKs? It would be awesome if you could justify your opinion. Is there a better approach that the above? EDIT: Anyone has a simple sample/algorithm to generate human readable identifiers for rows that scales well? If you're going to be

How to organise a many to many relationship in MongoDB

自闭症网瘾萝莉.ら 提交于 2019-11-26 10:30:48
问题 I have two tables/collections; Users and Groups. A user can be a member of any number of groups and a user can also be an owner of any number of groups. In a relational database I\'d probably have a third table called UserGroups with a UserID column, a GroupID column and an IsOwner column. I\'m using MongoDB and I\'m sure there is a different approach for this kind of relationship in a document database. Should I embed the list of groups and groups-as-owner inside the Users table as two

designing database to hold different metadata information

妖精的绣舞 提交于 2019-11-26 10:23:52
So I am trying to design a database that will allow me to connect one product with multiple categories. This part I have figured. But what I am not able to resolve is the issue of holding different type of product details. For example, the product could be a book (in which case i would need metadata that refers to that book like isbn, author etc) or it could be a business listing (which has different metadata) .. How should I tackle that? This is called the Observation Pattern. Three objects, for the example Book Title = 'Gone with the Wind' Author = 'Margaret Mitchell' ISBN = '978-1416548898'