Skip to main content

Questions tagged [relations]

The tag has no usage guidance.

34 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3 votes
1 answer
217 views

How to "merge" rows along with their foreign many-to-many relations without violating unique constraints?

Fiddle: https://dbfiddle.uk/-JLFuIrN Table CREATE TABLE files ( id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text ); CREATE TABLE folders ( id bigint GENERATED ALWAYS AS IDENTITY ...
Biller Builder's user avatar
3 votes
0 answers
7k 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 ...
SS''s user avatar
  • 155
2 votes
0 answers
23 views

Is there an algorithmic way to identify potential primary key foreign key relationships in postgres

I have a lots of tables in postgres with a lots of columns per each table. I need to write a program in such a way that it can identify the columns that can be a potential primary and foreign key pair....
Ashwin Prasad's user avatar
2 votes
0 answers
204 views

My relational schema and a few questions about relations and duplicate values in columns

I'm trying to create database in which I could store thousands of job postings. I put here 5 sample records of these job postings so that you could better understand how everything looks like: Now, ...
beginsql's user avatar
2 votes
1 answer
461 views

Modeling an either/or relationship

I've seen this post (How should I model an “either/or” relationship?) but it's not exactly what I'm looking for. both answers are suggesting creating a subtype instead of a relationship. Say I have an ...
Amarth Gûl's user avatar
2 votes
0 answers
3k views

Review the ER diagram regarding a National Football Team

We need to store information pertaining to football players who are or were members of the national team. For each player we store the following: first name, last name, date of birth, debut ...
user avatar
1 vote
0 answers
72 views

How to restrict allowed sub-entities in table referencing super-entity based on a type code

I'm working on my first db architecture for a platform containing several user types and that can exchange assets between them. There are also several transaction types, but each transaction type ...
Matheus Leão's user avatar
1 vote
1 answer
993 views

ER Diagram | Group, Post, User relationship

I need to design an ER diagram, but I am confused in a section, more specifically how to relate the post with the groups, because I need that post contains the information of in which group I publish ...
ontimond's user avatar
  • 111
1 vote
0 answers
337 views

Should I use Postgres' JSON columns for additional related data of different types and not yet known?

I have a simple database table, lets call it tbl_main with a few columns and relations to other tables via foreign keys. The tbl_main is the most frequently written to table, as in it receives new ...
kmindi's user avatar
  • 111
1 vote
3 answers
205 views

Putting foreign keys of several tables into the same column

I've never come across this situation, not sure how to go about it. Let's say I have a table Portfolio. I also have two tables: Asset 1, and Asset 2. I need to create a bridge between Portfolio and ...
George Well's user avatar
1 vote
0 answers
2k views

Is a relation with two attributes always in Boyce-Codd Normal Form (BCNF)?

I went through some tutorials on BCNF and got that a relation with two attributes is always in BCNF. My question What if a relation with two attributes has no prime or non-prime attributes? That is, ...
PS Nayak's user avatar
  • 121
1 vote
0 answers
80 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 '...
Rodrigo Ehlers's user avatar
1 vote
0 answers
321 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 ...
The Pointer's user avatar
1 vote
2 answers
64 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| ...
BPa's user avatar
  • 11
1 vote
0 answers
94 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 ...
Steve's user avatar
  • 11
1 vote
1 answer
89 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, ...
darkheir's user avatar
  • 163
1 vote
0 answers
168 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 ...
Perceval Dev's user avatar
1 vote
0 answers
187 views

ERD Diagram based on Crow's Foot model for Milky Way Jewelry

this was on my final exam this past winter exam season, in search for the answer since i got it wrong: Draw an ERD diagram based on the Crow's Foot model for a database to support the basic ...
david's user avatar
  • 11
1 vote
0 answers
138 views

How to use set-based statement instead of cursor for converting 1 table to two, keeping relations

I'm relatively new to databases and currently working with SQL. I am doing a conversion for a customer. This conversion points to local files on a filesystem. In the old database there simply was a ...
Jeffrey's user avatar
  • 11
0 votes
0 answers
33 views

Noobie needs help on designing database for membership management tool

I have searched through some of the database examples, but have yet to wrap my head around the logic of the relations between databases, so appreciate some support. Here is what I am trying to do: for ...
mor3dr3ad's user avatar
0 votes
1 answer
88 views

Store different data of the same format in one table, or multiple tables of the same format?

Consider I have the following MySQL tables: products id | created_at | updated_at | name | description | barcode stores id | created_at | updated_at | name | description | address product_attributes ...
user2190492's user avatar
0 votes
1 answer
52 views

How can I transform an exclusive constraint relationship from ER to RM model?

Let say we have two entities TEACHER and COURSE. There are two relationships between them. A TEACHER can teaches a COURSE, and also can learn a COURSE, however, the TEACHER cannot teach and learn a ...
xerez's user avatar
  • 1
0 votes
0 answers
271 views

Create a student-grade query from a relational database

I have three tables: Students (Id, name) Assessments (id, name, max_score) StudentAssessment (Id, student_ID, assessment_id, score) where ids are FK from the other two tables. I think this is the most ...
MartynW's user avatar
  • 103
0 votes
0 answers
115 views

Designing one to many relation where Many can be one of 2 entities

Apologies if this seems like a rather naive question but I'm relatively new to database design and I'm struggling to find the correct terminology to help source answers myself, so I'm turning here. ...
Niz's user avatar
  • 1
0 votes
0 answers
50 views

Should I create a linking table between two tables with existing IDs or add a column to an existing table

So I have two tables. Not with these exact columns but it's just to illustrate the point users id | forename | surname forms id | name Using MS SQL and was wondering what's best practice to link a ...
pee2pee's user avatar
  • 194
0 votes
1 answer
19 views

Convert generalization in ERD to Relationnal Database having no additional column

I've a quite simple problem but the litterature I came accross didn't seem to dwell on. Let's say I have an entity OFFER which represents an Offer on a Product, for each product, one offer can be &...
nprime496's user avatar
0 votes
0 answers
28 views

How do I restrict relations between entities to a parent entity?

I have a multi-vendor database for my e-commerce application. Below is a simple interpretation of my table and relation structure. Table: stores store_id (PK, AutoIncrement) Table: categories ...
Owen's user avatar
  • 3
0 votes
0 answers
41 views

Relationships overview with some many-to-many

Good morning/afternoon, I am currently beginning a new project and I wanted to design the database before doing anything however I struggle a lot with this design because it has some many-to-many ...
trenzalore's user avatar
0 votes
0 answers
270 views

Delete duplicate keys with relation algebra without count

Hi I am new to relational algebra. I was wondering if there is a way to remove the tuples from a table using relational algebra that have the same Value occurring in multiple columns or same column ...
sam's user avatar
  • 3
0 votes
1 answer
660 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 ...
cphill's user avatar
  • 115
0 votes
1 answer
46 views

Why do I need this attribute?

This is my relational schema; Book(title, shelfmark, ISBN, author, year) Genre(name) GenreBook(name, ISBN) User(firstName, lastName, cardID) UserBooks(cardID, ISBN, position) Why do I need the ...
bog's user avatar
  • 101
-1 votes
1 answer
2k views

Update all rows with a one to many relationship count in the same table in MYSQL

I am trying to update all rows of a MYSQL table with the total amount of referred users for each user. 1 user can refer multiple users and I need to run a MYSQL query to update the invite count (total ...
webmaster8800's user avatar
-1 votes
1 answer
302 views

Structure to represent matches between teams or individuals

Say there's a sport that can either be contested between two individuals, or two teams comprised of several individuals. So obviously we need the standard players, teams and teams_players tables. But ...
cb7's user avatar
  • 135
-1 votes
3 answers
427 views

Given a table containing class and students, need to find the diff in students

I have class_students table where given 2 class ids I need to find the diff in students. This is sql fiddle that I used, http://sqlfiddle.com/#!9/dba48e/11 Any help here.
Lokn's user avatar
  • 99