Skip to main content

All Questions

0 votes
1 answer
63 views

Is it good practice to duplicate the connections to the grandparent in the parent and son in SQL? [closed]

I've seen different database designs in different projects. Some of them claim that from son to grandparent one should go through the parent (intuitively correct); in others there is a lot of ...
Polikarpos Goldshtein's user avatar
0 votes
1 answer
143 views

Is it bad practice to store a foreign key like user_id in all related model tables even if some of those models are children of related models?

We have 3 models: Users which can have Orders which can have a Transaction (like a credit card transaction). Does it make sense to store the user_id on transactions or is that considered bad practice ...
glesage's user avatar
  • 965
0 votes
1 answer
309 views

constructing a followers/following relationship [closed]

A relationship between users and followers is many-to-many. My model: type User struct { gorm.Model Username string `json:"username" gorm:"unique"` Name string ...
darkstar's user avatar
  • 928
-3 votes
1 answer
458 views

Db design relationship between n:n tables?

I have poor skills for db design and I need some help about relations setup. So use case is: User which can be Coach or Client. Client can have many coaches and coaches can have many clients. Coach ...
1110's user avatar
  • 7,247
-2 votes
1 answer
66 views

Database design - Storing keys to all required information vs performing Joins when authorizing access [duplicate]

Take the following examples (Only pseudocode) when considering whether a "Company" has access to see information about a "ClientSale". Either I can store the FK references to ...
Thomas Fox's user avatar
1 vote
1 answer
587 views

Chicken-and-egg problem in with foreign keys

How do I create and insert rows to the following table schema in PostgreSQL: Table: employee emp_id, emp_name, emp_dept, emp_manager Table: department dept_id, dept_name, dept_manager emp_manager is ...
0xFF057DC's user avatar
0 votes
1 answer
528 views

Databases: Foreign key duplicates

I'm trying to understand something about the foreign key of a database. I couldn't find a clear answer for this. The definition of a foreign key goes something like this, "Foreign key is a field ...
pineappleFrenzy's user avatar
1 vote
1 answer
42 views

what is a better way to create table?

I have mechanic that provide some services and there may be several services provided by a mechanic and how is better way to make tables in this case? What i have now is : Mechanic table : create ...
besidethejokes's user avatar
0 votes
1 answer
1k views

Can weak entity has more than one primary key if it has more than one strong entity?

If I have a weak entity with no attributes and has a four weak relationship with the owner entities and I want to design the relational schema for this weak entity, Can I take all primary keys of the ...
user avatar
-1 votes
1 answer
50 views

Database: foreign keys between class and just 1 of the subclasses. Use single FK column?

I'm reworking and extending an existing data model where a section covers person data. The current person table is just 1 big table containing all fields, both for natural and legal persons and the ...
vulcan's user avatar
  • 13
1 vote
2 answers
68 views

How can I constrain or choose between one or other foreign key?

The problem is conceptual (databases relationships), so the language isn't the focus here, but I'm using Python and Django. I have 3 models/tables: Company Customer Address Eg. class Company(models....
André Vicente's user avatar
0 votes
1 answer
313 views

SQL - Foreign Key and Primary Key not Matching

I am new to SQL and I am running into trouble. I have 3 tables: CREATE TABLE indexCodes { (indexNum VARCHAR(5) PRIMARY KEY, courseString VARCHAR(10), title VARCHAR(20) } CREATE TABLE user ...
Sharia Hussain's user avatar
0 votes
1 answer
177 views

B2B ecommerce customer special price database design

I am currently building an B2B ecommerce site. Currently i am stuck at defining special price for a customer for a specific item. I have two tables which is: Customer (Regular customer details, like ...
Muhaki's user avatar
  • 140
0 votes
1 answer
343 views

Sqlite foreign key reverse cascade delete

I have two tables movies and songs. songs have the foreign key in movies. I need to delete the movie entry when all the songs referenced to the movie is deleted. just like reverse cascade like many to ...
Nandu's user avatar
  • 11
0 votes
1 answer
174 views

There are no primary keys that match? - SQL Server Management Studio

I have a Resume table like this: And I'm running this: CREATE TABLE ResumeSkill ( ResumeSkill_ID int primary key NOT NULL Identity(1,1), Resume_ID int foreign key references Resume(...
Melanie's user avatar
  • 317

15 30 50 per page
1
2 3 4 5
13