SQL Server tool that allows navigating through key relationships - sql

Does anyone have a knowledge of a tool that allows to navigate over reliationships between entities in sql server database?
I want to be able to list all rows in a table and then (for selected row) jump to all rows that match (in a context of relation between tables).
The same thing can be done in LINQ to SQL by querying navigation properties but it's not convinient to do this in code all the time.
I tried to use LINQPad but query results are not interactive in this way - again it can be done in code.
Thanks for answers in advance:)

Try PL/SQL Developer, It should be working as you expect.
For eg: If we view a table, the 1st few rows of the table will be shown.
Then when you want to go to a child table or parent table from that. You had 2 types of hierarchy button for each.
The button circled in image was one of them. And this one particularly was for finding child references from this table.
On clicking it you will be show you the table references from this table using the foreign key relation ship. And on selecting one of them it will change the sql query to filter out with the table and column you selected.
The application was a bit different from other tools out in market, but once you got to know how to use it.
I think this is their home page

Related

ODBC call failed Violation of primary key

(Beginner of SQL so I do apologize for any novice mistake that I made)
So essentially, I'm currently making an access form that allows the user to update their stock inside the warehouse. I'm using the ODBC link database in which I can store various data inside the server (the configuration for the database will be seen down below)
However, when I created a combo box that linked to a column(IDDH), it automatically pops up an error stating that it is violating the PK constraint whenever I switch to another column.At this point I don't know what I did wrong since I already connected two tables with a relationship of one-to-many inside the SQL along with connecting it on Microsoft Access(Just in case). And connect Foreign Key in the dbo.DonHang table (ProductID)
Here is my configuration
SQL:
Relationship in Access
The error in the access form whenever I switched to a different column in the combo box
If you want to require more information. Please do not hesitate to ask.
You base one form directly on the main table. Not a sql join.
You then create a sub form with the "many" entries for the one record. And again that form is NOT based on some sql join, but ONLY the linked child table.
You don't try and use sql joins to solve this kind of data editing in Access (using sql server does not change this). So you need a main form (based ONLY directly on the ONE linked table of master (parent) records. You then have a sub form and again it is based directly on the child linked table (again not some sql query).
So, for editing main records and child records? you use a form + sub form in Access to achieve this goal. And this setup will also work well with sql server linked tables.
But all in all? You don't try and edit sql joined data. you build up the main form, and drop in a sub form to a classic and common editing of master/child data in Access.
If you really want to edit both as one row? Well, you can often edit but you not be allowed in general to add rows. But if the sql VIEW you create allows editing of rows (you can test/try this in SSMS), then if you save that query in SSMS as a view? Then simply link the view to Access and you can edit the one row, but there are limitations in terms of adding new rows etc. it really depends on your goal.
but, at the end of the day, editing of master + child records is NOT achieved by a sql join query, but that of editing each table separate, or a form + sub form in access.

SQL - Select data from three tables where one table has multiple foreign keys to the same primary key

I have the following tables and relations:
When I create a User, that user gets a CurrentWeekrow and that current week row in turn gets a CurrentWeekStatusrow. The user can add food items to the Foodtable and then can choose from these food items and select a few to insert in CurrentWeek.
In the client I want to grab CurrentWeekas an object that has a list of Foodobjects and a list of their corresponding status.
I am struggling as to how to make this happen. I think this can be done by making multiple queries to the database, one to fetch CurrentWeek and then from this extract all the FoodId's and make separate queries to fetch each Food. But this seems like a very bad solution.
The other solution I can think of is making a view with all the necessary data. But I don't know how to make this view and even if I manage to make the view I don't know how to separate each Food into different objects.
Do anyone know of a good way to accomplish this?
I use NodeJs as a REST API and Android Studio with retrofit to send REST calls.
After consulting StackOverflow and a few colleagues I changed the initial database schema into:
This was a design I initially chose to not go with as I thought adding one row on the CurrentWeek table for each user would be better than to add many rows for each user in the PlannedFood table. I see now however that this design have a few advantages as compared to the other design.
Designing it this way also solves my initial question as I can now grab all the rows in PlannedFood for a specific user, joining on FoodId and then map the Food data into a Foodobject on client-side.

Query in light switch returns only one line?

I have a query which is called by two Parameters Invoice number & Company name. the query returns always one line in Light switch. Usually it should returns more than one line (Depends on what invoice number I am looking for). I donot know why its always returning one line ? The query is connected to a view in SQL server. I tried to test the query in SQL serve and I always get the correct lines. but when i call the same query with the same Parameters in light switch it gives me only one line as a result. Any idea why?
Usually this is caused when the primary key(s) for the table have duplicate values in the data returned. Look at the entity (in the LightSwitch Entity designer in the server project) LightSwitch created when you attached the view and see what it thinks the primary key(s) are.
In order to solve this problem:
You just have to create or add anew Primary Key to the current keys in your view.
Best Regards,
Mohamed

How to get reference information between parent and child tables (MS SQL Server/MSAccess)?

Is it possible to get information about whether a child table has reference to a parent table through a certain record? For example, tblParent has a record whose primary key value is 5. I want to know whether tblChild_A, tblChild_B and tblChild_C have one or more records in them where the foreign key value is 5. Well it's definitely possible by querying each of the child tables individually but I want to know whether there's any system query or stored procedure or whatever that produces a tabular output from all those tables together.
If it's possible in MS SQL Server then please also inform what's its counterpart in MS Access. Regards.
Lots of arguments here. I want to know how this can be done in MSSQL Server as well as MS Access.
I described a possible solution on how to do this in SQL Server here: SQL Server: how to know if any row is referencing the row to delete.
Access/Jet/ACE offers no such system query/sproc for this purpose. You'd have to code it up individually, though if you wanted it to be generalized, you could use the TableDefs and Relationships collections to figure out what tables to look at.

Access 2003 - Create and Delete Many-To-Many associations

I need to develop a front end to a MSSQL database just to modify a few tables. I decided to use Access 2003 simply because of time restraints.
I used Linked Tables over ODBC to get them into Access, I'm designing the forms but I'm having problems creating an interface to allow users to create and delete new association between entities.
My Database structure is:
product
# productcode
- name
product_part
* productcode
* partnumber
- position
part
# partnumber
- comment
There is a many-to-many relationship between product and part (a product can have many parts and a part can belong to many products) except I can't find any easy way to allow a user to just associate a new part to product, only view the existing ones.
I've defined the relationships in Access except the options for cardinality and referential integrity are greyed out, I'm assuming this is because they're linked tables? Not sure if this would affect anything.
I created a form for product with an embedded subform which lists all the associated parts and their position (position is an attribute of the relationship since it's contextual but I can spin this out into it's own table if it'll make things easier).
Basically I need to make an user interface mechanism which will associate a selected part from a list to the shown product or any other way to create new and delete existing associations flexibly. I would have thought Access would have something in some wizard somewhere to do this, but if it does I can't find it.
Any help would be appreciated.
Judging on what noted so far, then this should be a simple matter to have the main form based on your topmost table (product). The continues sub form should then be based on ONLY the product part table.
If you think about this, the third table is really only a lookup table there for your convenience to allow you to not have to type in manually type in the part number.
So, base the child sub form as a continuous form, and make that column for part number a combo box that looks up the part numbers from the third table (part). So this combo boss can search and display by description, but will in fact automatically store the part number in that colum for you.
So while there's no need for any types of wizards, you certainly do not have to write any type of code whatsoever. Just ensure that the master child link settings for the sub form are set up correctly, and access will thus insert and maintain The product code columns used to link back to the main product table. You can most certainly use the combo box wizard to create the combo box in the continuous sub form that you're going to use to Select what part and set the part number column from the parts table.
The result will be a form that allows you to add new part assemblies or edit existing. While access will maintain the product code column for you, if you delete a main record, you'll need to have setup referential integrity and cascade deletes on the back end database part. So as you correctly note, all the integrity features will be set up in the database back end, not in the access front end part.
I've discovered what I wanted to do isn't easily possible using Linked Tables, I was able to do what I wanted to do easily if I used native access tables (since it let me properly define the relationships) but I couldn't do that with linked tables.