Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [relations]

The tag has no usage guidance.

-4
votes
0answers
20 views

How to get temporary table based on two queries [on hold]

select mst064_constunit, mst007_unitname, mst064_constcode as constcd, mst064_constname ...
2
votes
0answers
24 views

A multiple choice question, with multiple or only one correct answer, and sometimes no correct answer

It's a question & answer based model, and here is the scenario: A question with multiple choices given, with 3 to 7 correct answers among those choices. A question with multiple choices given, ...
0
votes
2answers
46 views

Are Cataloge and relation cache in PostgreSQL per connection or global to the server?

I am trying to figure out if Postgres' relation and catalog cache are per connection or per server? I did find that plan caches are per connection. It would make sense for the cache to exist for as ...
1
vote
0answers
31 views

Database pattern with two types of owners for an object. Like how users and groups can make posts in FB [duplicate]

Please help. There is a problem I have tried to resolve for some time now. I want to come up with a pattern where i have a table with advertisements on a web platform. These advertisements shall be ...
0
votes
1answer
23 views

Table Relationships for Property Bags Configuration

I am creating a database table setup for user preferences in my application based partially on this design and while I created the tables and foreign keys, I can't seem to figure out the relationships ...
0
votes
1answer
90 views

Is it good practice to create a separate table for views count?

I have created a blog table where I'm having a field called views_count but I have heard that updating the views_count field on each page view is strain. So I have created now a seperate table for ...
-1
votes
1answer
21 views

Creating blog fresh tables from old tables [closed]

I am re-creating a database structure from old tables. New tables should be optimized and easy to understand. In old database the developer used video table name for storing video blogs. However I ...
2
votes
1answer
161 views

BCNF decomposition does not prevent insert anomaly?

I am in the process of designing a schema for a simple polling app and have tried to normalize it with the decomposition algorithm from this lecture. Requirements A poll has a unique id (poll_id), a ...
0
votes
1answer
39 views

Recursive Relationship [closed]

I have an application, which contains two Models Question and Option Each Question has many Options Each Option may have many Questions (and this Question may have many sub Options) so on and so ...
0
votes
1answer
41 views

mysql join many to one table and display each 'many' record as an additional column

I have a many to one table. For example: user_id, name 1, chris 2, john and user_id, item 1, apple, 1, banana, 2, orange How could I run a query that returns something like this: user_id, ...
1
vote
0answers
58 views

Normalizing a relation schema with 'abstract' attribute names

I'm a student currently attending a database design course and I'm having some issues normalizing 'abstract' attribute relation schemas from 1NF all the way to 3NF. When we used examples with '...
1
vote
1answer
54 views

LOB in frequently queried table or separate table

I have a table named FinTrans in an Microsoft SQL Server 2012 server with approx 10K-30K records at any given time and about 2K records are inserted and deleted each day. The table has 3 nvarchar(...
4
votes
2answers
181 views

Is the inverse of Armstrong's Axioms valid as well?

I have been looking into Armstrong's axioms a little bit. In a homework[1] exercise I was asked to prove A→G is in F-closure. I managed to get it at this point: AB → GB Being at this point, can I ...
0
votes
1answer
37 views

Show multiple joined rows

I have a simple relational MySQL database with users, cars an a log table. Everything works fine. In the log table I want to 'register' the users of a car. But a car can have two users at the same ...
5
votes
3answers
72 views

Constraining data based on related data in a different table. Should this be done on the database level or the application level?

I am working on a database that contains our customer information as well as information about our vendors. Part of that includes matching our customers with our vendors, the account numbers those ...
1
vote
1answer
354 views

Circular dependency between 2 table with one to one and one to many relationship

I have 2 tables in SQL database, User and Company. User belongs to one company. So user table has UserID & CompanyID (foreign key) Company can have multiple users. One of them will be the ...
1
vote
1answer
63 views

Table with relation to two others (three-way relation?)

I stumbled across a weird situation that one table has relation to two others but record in it can only have a relation to one of the tables. To clarify things, I have tables: attribute, visit, ...
1
vote
1answer
35 views

Difference of sets with different amount of columns?

Problem When there exists two sets, R and S, and we take the difference R - S, we remove the elements from R that exist in S. For cases where the number of columns are the same on both sides, such ...
37
votes
2answers
8k views

Is it a bad practice to have several mutually exclusive one-to-one relationships?

Say, a table car has one-to-one relationship to tables electric_car, gas_car, and hybrid_car. If a car is electric_car, it can no longer appear in gas_car or a hybrid_car, etc. Is there anything ...
3
votes
1answer
493 views

What is the definition of bad circular dependency?

I have been searching for while for a good resource, where the circular dependency is well explained, unfortunately nothing good found. Therefore I tried to understand exactly which kind of circular ...
0
votes
1answer
54 views

One to Many Relationship: Describing the Tables

If we have two tables in a One-to-Many relation ship, is there a standard name to properly refer to the tables? For example if I have a table of books, and a table of authors (ignoring for now the ...
0
votes
0answers
20 views

What is the best way to define relations between two of the same entities?

I have a users table and I want to define a peer-to-peer kind of relationship between certain users. My idea is: A user wants to connect his/her account to another user. Initiates the connection The ...
1
vote
0answers
113 views

DBMS Query Preprocessor Checks Semantics or Syntax?

I encountered the following statement when reading about the constituents of a query processor in a DBMS: ... (b) A query preprocessor, which performs semantic checks on the query (e.g., making ...
0
votes
3answers
1k views

Return “parent” rows where only one “child” record exists in one-to-many relationship

Having a one-to-many relation, I am trying to get records in the accounts table where only one record exists in the accounts_prop table. I have the following query, but it does not do the desired. ...
2
votes
1answer
327 views

Database relationship inheritance [closed]

I have a vehicle sales store. In my store I sale many kind of vehicles for example cars and boats. And I would like to keep track of the sales. My vehicles has some attributes as: Arrive on store ...
2
votes
1answer
321 views

Mysqldump subset of database with relational data using a master table

I have found a lot of articles describing the concept of exporting and importing relational data, but I have not been able to find any article describing this more generally for a MySQL database, ...
1
vote
2answers
57 views

3 different queries from 2 tables

I have three tables (palettes, boxes, layout) with sample values: Palettes |ID_P|sign| | 1| P1| | 2| P2| | 3| P3| | 4| P4| Boxes |ID_B|sign| | 1| B1| | 2| B2| | 3| B3| | 4| ...
3
votes
0answers
2k views

How do you perform the chase test?

Trying to follow the chase algorithm as I understand it, If two rows agree in the left side of a functional dependency (FD for brevity), make their right sides agree too. Always replace a ...
3
votes
1answer
63 views

Equivalent functional dependencies

I cannot understand why F1 is not equivalent to the other sets of dependencies below given the relation R(A,B,C): F1 = {A → B, B → C} F2 = {A → B, A → C} F3 = {A → B, AB → C} This is question no. 6 ...
3
votes
3answers
605 views

Contacts table with multiple entries?

Here is a part of our Database: Table: Users ID INT First Name VARCHAR Last Name VARCHAR Email Address VARCHAR ... Table: Contacts ID INT User_id INT (Foreign Key)...
1
vote
2answers
2k views

Counting distinct entries in a column using relational algebra

So I have a table similar to this one. Each user has posted a review about one or more hotels(A,B,C,D) but on different dates so there are no duplicate tuples even though a person might have reviewed ...
0
votes
1answer
69 views

MS SQL DB design help

I'm stuck with table design and query FOR XML Sync engine for Ads requires XML schema in this format <attribute1>value</attribute1> <attribute2>value</attribute2>… <...
4
votes
5answers
373 views

What is the best practice for selecting from two tables with multiple relations?

I have two tables with a structure like below: and am selecting the data with below query: SELECT (SELECT Name FROM Management_EnumerableItem ME WHERE ME.ID = DN) DN, (SELECT Name FROM ...
2
votes
1answer
767 views

Proof that Inner Join is Commutative

I'm trying to prove to myself that the order of inner joins doesn't matter, but, in an abstract sense, I'm coming up with nothing. How would one go about proving that the order of a set of INNER ...
0
votes
1answer
59 views

In a school database, do I need to have repeating data when a student can also be a teacher?

I've seen lots of ERDs of schools, teachers, and all the junction/associative tables. They always have three tables: Teachers Students Associative table betweeen them, maybe subjects of something ...
3
votes
1answer
473 views

Functional dependencies proving method

I was having some difficulties when trying to use Armstrong axiom to solve functional dependencies. R (A,B,C,D,E,F) Given FD = { A->CD , C->BE, B->F, F->A } Prove A-> BF By using ...
0
votes
1answer
40 views

DB architecture: What if a table is part of another table

My SQL Server database has the initial table named Lead. This table has all kinds of info about a lead person. It has 3 foreign key columns: IndustryId, BusinessTypeId and ReferenceId. I have a ...
1
vote
0answers
72 views

Table Relationships: Table 1 (Field 7, Field 8, Field 9) to Table 2 (Field 1)

I'm sure that this is probably 'Databases 101', but I can't seem to figure it out. So, I'm setting up a database in Access - that I will want to move to MySQL, and I currently have 4 tables, set up ...
3
votes
3answers
71 views

Meta-relationships (Relationships between relationships) versus tuples

I am designing a database which needs to store some fairly complex relationships among many different types of entities. In the simplest example, let us say I have three types of entities - "Student",...
0
votes
2answers
59 views

Normalization of a table

I am trying to normalize the following table but having some difficulties Mem_id mem_name phone email Book_num Book_titl Author_nam publication edition 100 smith 12443 eml1 200 physics ...
1
vote
1answer
18k views

Structure a database for a Blog

I built a database for a blog. I am a student yet, so my knowledge is limited in this area. I post this question to get a briefly description of what I do wrong, why, and how I can fix it. I'm not a ...
1
vote
1answer
72 views

Many-many relation with specific type

Sorry if this question has already been asked, but I didn't find it performing a search. I have 2 tables (table_a and table_b), linked by a many/many relation. The relation can be of two types, ...
1
vote
0answers
141 views

Mysql InnoDB relations vanish when exporting/importing to online database

My issue is the following : I have a local database running on EasyPhp server : WEB server : Apache/2.4.7 (Win32) PHP/5.5.8 DB server : 5.6.15-log - MySQL Community Server (GPL) PHPMYADMIN : version ...
2
votes
1answer
929 views

What is the cardinality of entity relationship between Employee and Department?

Recently, a friend of mine asked me this question about the cardinality between a Department and Employee entities, I replied many to many, then he, my friend, showed me drawings from the internet ...
5
votes
1answer
351 views

How can I avoid this circular relation?

I based my account/user table design following this article. So I have set my table relationships to look something like this: User <- Memberhip -> Group -> Account With this design, a user ...
2
votes
1answer
699 views

Conditional relationships? One-to-many relationship using a pivot table for only a type of entity

I have the following tables: users: - id - name - user_type_id (references id on user_types) neighborhoods: - id - name homes: - id - house_number - neighborhood_id (references id ...
-4
votes
2answers
45 views

Postgres relationship statement [closed]

Lets say I have the table parents. A parent has many kids and a kid has many toys What would be the best way to do a SELECT statement for the parent and grab all of kids associated with that parent ...
2
votes
1answer
3k views

Unique key based on many-to-many pivot table

I have to manage artists and albums tables: | artists | | albums | | album_artist | +--------------+ +--------------+ +--------------+ | id | | id | | id ...
2
votes
1answer
146 views

Multiple columns from one table rely on one single table

I'm working with PostgreSQL 9.2 and have the following relation between 2 tables: The table town stores a list of town codes. The table perimeter stores perimeters denomination. Towns are almost ...
0
votes
2answers
61 views

Multiple one-to-one relations

I'm trying to design database relations for archaeological places in a country. There are around 9000 places registered. An archaeological place can have multiple types. Types will be like Cave, Mound,...