Employee Hierarchy at different levels [closed] - sql-server

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have 5 tables in my database called Employee, Company, Team, Locations and Position. Now Positions are assigned to employee on each of these levels i.e. to Company, Team and Location. To resolve this I have created 3 tables called CompanyPosition, TeamPosition and LocationPosition. An employee can hold multiple positions in each of these level i.e I can be a CEO, MD at company level etc.
Now I have a situation that in each of these position tables an employee can hold multiple positions and he will reports to someone holding multiple positions, but to only one of position at a time.
I am thinking of creating a new column called ReportstoPositionId in each of these tables CompanyPosition, TeamPosition and LocationPosition to solve this problem.
Can anyone suggest me that I am going in right direction or it can have some problem now or in furture.

Related

Need to redesign this ER Diagram [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 11 months ago.
Improve this question
I want to design them drawing an ER Diagram.
I have already designed an ER Diagram but teacher told me that it has only 5 entities and I need at least 7 or 8 entities. Also told me that I must not add primary key to a relationship(diamond shape).
So my question is how can i achieve this?
Here are the entities and properties of my database.
User – (user_id, username, profile_picture, member_date, user_gender, user_email)
Movie – (movie_id, movie_name, movie_year, movie_country, movie_description)
Review – (review_id, user_id, movie_id, review_score, review_date)
Actor – (actor_id, actor_name, actor_birthdate, actor_gender)
Genre – (genre_id, genre)
Director – (director_id, director_name)
Movie_Genre – (genre_id, movie_id)
Movie_Cast – (actor_id, movie_id)
Movie_Director – (director_id, movie_id)
I think the answer to your diagram questions is right there in your entity list. You have an entity named MOVIE_DIRECTOR but in the diagram you have a relationship named DIRECTS. You just need to change all your relationship diamonds to appropriately named entity rectangles and most of your issues will be resolved. For example, the relationship named "HAS" should really be the entity named MOVIE_GENRE.

In one to many relationship does there exist element from first table that are not connected to element from second table [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
when we have two tables, suppose A and B,there exists one to many relationship between these two, than can there be element from A that are not connected to any element from B?
One to many relationship between relational tables is a concept that primarily means that if there is a record in table A, then it can have many associated records in table B.
For e.g. customer_id record in table A can have many loans for that customer in table B.
So 1 customer_id associated with many loan_ids in another table.
Coming back to your question, it is possible that 1 loan_id in loan_table can have multiple guarantors in guarantor_table and it is also possible that a loan does not have a guarantor associated with it. So even though there is one to many relationship between the tables it does not mean it will always have many records in table B for one record in table A.
Check this link - What is the difference of partiality and optionality when drawing ER diagrams

Database design for relationships [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have 3 tables
Table1: Plant Table
PlantId(Primary key)
Plantname
and some other fields
Table2 :Inputfiles
Plantname,Filename
PlantId(foreign key) references PlantId(Plant)
Table 3; InputData
Id.
and other fields
I need to design it such a way that one plant can have many inpufiles So this is a 1-m between Plant Table and Inputfiles tables
Now when the user selects a inputfile from table2, all the data related to the input file is stored in Inputdata table3.
What should be the relation between table2(input files) and table3(inputdata)
Thank you
sun
A 1-1 relationship should exist between inputfiles and inputdata.
Based on your description of the problem, I would have inputfiles have the inputdata.id as a foreign key.

Database design questions, what do you think? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have the following entities in my system: COMPANY, POSITION, APPLICANTS. There is many to many relationships between POSITION and APPLICANTS, but the current model does not show that there is many to many relationships between COMPANY and APPLICANTS.
Does it make sense to you to have a join table foo that has the company_id, position_id and applicant_id or i should have a table that joins COMPANY and POSITION and another that joins POSITION and APPLICANTS?
I don't think so. You can get APPLICANT for a given COMPANY via JOIN with POSITION.
I think a relationship between a COMPANY and an individual becomes significant when they shift from APPLICANT to EMPLOYEE. I would not model it as you propose.

related categories - database design [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 months ago.
Improve this question
I'm looking for a little database design advice...
I have a spreadsheet with a few columns in it. Column 1 being a list of categories and the rest being related categories(to the category in column 1). I'm trying to figure out what the best way to setup the tables would be... My thought so far is to have a table that just lists the categories then have a table with 2 columns that holds the id of the category and the id of a related category.... Would this be the best way to do this? Any better ideas?
A self referencing table (parentId to childId) is how most people implement a hierarchical structure like the one you are describing.
Your way is the best. Academics would call it resolving a reflexive many-to-many relationship with an associative entity, but it's nothing more than what you described.
m:n relations should always (maybe there are exceptions) be made with extra table for relations. So it should be the most flexible solution

Resources