Is It Possible To Make Use Of Database Relationships In A Join?

Aug 2, 2004

When you make a join, it may look something like this:

SELECT Products.ProductName from Products, Categories
WHERE Categories.CategoryName = 'Seafood' AND
Products.CategoryID = Categories.CategoryID

In this query you use 'Products.CategoryID = Categories.CategoryID' to give the relation between the two tables. But if you already added the relationships to your database, this should be known.

My question is, why is it necessary to add the relation in the query when the relationships are already in the database? Is it somehow possible to ommit the relation in the query and make use of the relationships in the database.

Kind regards,
Iwan Rotteveel

View 5 Replies


ADVERTISEMENT

Inner Join/where Vs. Enterprise Mgr Relationships

Apr 9, 2007

Hello, I am new to SQL and the site, thanks for taking the time to look at my post

I have been building all of my queries using the WHERE clause (which i read functions the same as an INNER JOIN) to deal with my related tables. my boss wants me to look into the functionality of the "Relationships..." option in Enterprise Manager to see if it is more efficient to use and would eliminate the need for a WHERE clause

i have created some relationships using this "Relationships..." dialogue box to test out what happens (without using WHERE in this test scenario), the output seems to remain the same except for the fact that it looks like more rows are being queried to determine which ones are related

can you help me understand what the benefit of doing Relationships through Enterprise Manager is as opposed to using WHERE clauses to join related tables?

View 2 Replies View Related

How To Do A JOIN Statement For A Table With 2, One-to-many Relationships.

Nov 9, 2005

Hello,I want to be able to view data from 3 tables using the JOIN statement, butI'm not sure of how to do it. I think i don't know the syntax of the joins.Iimagine this is easy for the experienced - but Im not.Allow me to explain:I have 2 Tables: PERSON and SIGNPERSON------PersonNo int (Primary Key)Name varchar(50)StarSign intFavFood intSIGN----StarSign int (Primary Key)StarSignName varchar(50)Relationship: SIGN has a one-to-many relationship with PERSON. The linkingfield is called 'StarSign'.Question 1:I want to display all the peoples names, and their star sign (whether theyhave one or not).Answer 1:SELECT PERSON.Name, SIGN.StarSignNameFROM PERSON LEFT OUTER JOIN SIGN ON PERSON.StarSign = SIGN.StarSign;No problems there. But now I want to do the same thing, but have theirfavourite food displayed as well. So an additional table is needed:FOOD----FavFood int (Primary Key)FavFoodName varchar(50)Relationship: FOOD has a one-to-many relationship with PERSON. The linkingfield is called 'FavFood'.Question 2:I want to display all the peoples names, their star signs (whether theyhave one or not), and their favourite food (whether they have one or not).Answer 1:???I'm not sure what to do. Notice that I want to use an LEFT OUTER JOIN so ALLthe rows from table PERSON will appear 'irrespective' of whether they haverelated records in the other tables.Jack.

View 3 Replies View Related

Make A Join In Between 2 Tables?

Jan 17, 2012

I am trying to make a join in between 2 tables. One table which we can called func has 2 columns a and column b.

The other table which is called export has 16 columns. I will like to make a join in these tables and insert the result of the join into another table i have.

The table that is going to have the information has 4 columns, so I will get 1 column information from table export, and the other 2 column from table func, the other column shall be left in blank for the time being.

The problem is also that when i make a select from table export, there are only some values i want to get, this are values from a period where there is only the periods 11.

Select Company, A and B

FROM FUNC, EXPORT where period = '1101', '1102', '1103'

insert into new table?

View 7 Replies View Related

How To Make Correct Join

Apr 4, 2006

HiI have to tables one called GROUPS and one called ACCOUNTIn table Group I have the follwing fieldsGroupid, AccountFrom, AccountToIn table Account I haveAccountNo, Name etc.Records in Groups:P1, 1001, 1002P1, 1005, 1007P1, 1010, 1010P1, 1007, 1012Now I want to have the corresponding AccountNo from ACCOUNT (from rangeAccountFrom..AccountTo), that is the following result:1001100210051006100710081009101010111012If f.x. 1008 doesn't exist in ACCOUNT this should not be listed. Theresult will be used in another view.My problem is that I also get every other record from table ACCOUNT.Do anyone out there have a solution on my problem ?BR/Jan

View 4 Replies View Related

How To Make This Join Statement In SQL

Apr 15, 2008

hi, so first of all, I am using SQL and VS C# 2005 express.
I have 4 tables as follows (I omitted some fields for simplification)

Address (street, city)

Seller (FirstName, LastName, AddressID)
Buyer (BuyerID, Pseudo, AddressID)
Transaction (OrderSerial, BuyerID, SellerID)


now, I want to make an sql statement in order to retrieve the following fields

Transaction.OrderSerial | Buyer.Psuedo | Buyer.AddressStreet | Buyer.AddressCity | Seller.LastName | Seller.AddressCity.

well you get the idea here. the problem I am having is that both seller and buyer are linked to the same table address. so I don't really how to do the join statement here. please help about this.

View 4 Replies View Related

Database Relationships

Aug 22, 2006

While playing about with SQL Server 2005 I am sure that I saw a tool to do relationships the same was as in access - however now I can't find it.

Am I seeeing things or does this really exist?

View 2 Replies View Related

How Do I Transfer Tables And Relationships From One Database To Another?

Aug 24, 2006

Hi, I'm working on Sql Server 2005 Express and I'm trying to transfer over some of my tables with the primary and foreign keys relations as well as the data in them from one asp.net 2.0 website to another.But I can't seem to find the Import/Export option in Sql Server 2005 Express Edition, does anyone know how I can do this?Thanks in advanced.

View 1 Replies View Related

Discover Relationships Between Existing Tables Of A Database

Mar 23, 2007

Hello Friends,
I am right now working on a project that has a database with over 100 tables in a database. Because of extreme time constraints the developers didn't build in any relationships or constraints between or in the tables. Now I need to remodel the database such that the database is more structured and normalized. I don't have much knowledge about the database design since it is a 2 year old application and the person who developed the database is now gone. I know remodelling the database would require knowledge of the existing database and business rules.
I was wondering if there are any tools that could suggest or discover relationships between tables. For eg. Lets say there are two tables named 'Customer' and 'Order'. I notice that there is a column named 'id' in Customer and a column named 'customer_id' in Order. So I ask the tool to discover a relationship between id and customer_id and it tells me that there is a one-one or one-many or no relationship by comparing values. I heard ERWin would be able to do that but thats expensive. Please do let me know asap.

View 2 Replies View Related

Transact SQL :: Possible To Get Table Relationships Information From Database Diagram?

May 5, 2015

I'm using Sql Server 2012 Enterprise and have a database with over 400 tables. I am looking at one diagram which contains about 20 (or so) tables and their relationships. When I right-click on a relationship line I only see information about which tables are connected on that line but not on which fields.  Can I get that information from the Diagram or can I only get that from the sys tables?

View 2 Replies View Related

DB Design :: Buffer Database - Insert Information From Partners Then Make Update To Main Database

Oct 29, 2015

I actually work in an organisation and we have to find a solution about the data consistancy in the database. our partners use to send details to the organisation and inserted directly in the database, so we want to create a new database as a buffer database to insert informations from the partners then make an update to the main database. is there a better solution instead of that?

View 6 Replies View Related

Best Way To Make A Database Not In Use?

Apr 9, 2006

Hi.

I am almost wrapping up a project of my own and I will have the option to restore the database, so dropping the existing one and then running the SQL script to create the database, tables, stored procedures and so on.



My question is, (using .NET 2.0 C#) - what is the best way to resolve the "cannot drop database as it is currently in use" message, or some message of the similar sort?

Even though I specified "USE MASTER" in the commandText string, there will be somewhere, in a situation, where the database will still be in use.

How can I forcefully make it NOT in use, drop it and do other things I like to?

What is the best way?



Many thanks!

View 9 Replies View Related

Make A Copy Of Database

Nov 17, 2006

Hi:
 I have installed sql server 2005 express and SQL Server Management Studio Express
How can I generate a database from another copying the structure and data?
 For example I have a database named Customers, I need to make a copy of Customers named Customers2. Customers2 also will be attached to the same Database Engine Server where Customers is attached.
How I Can do it?
Thanks!
P.S.
I tryied to make a copy of mdf an ldf files from Windows Explorer and renamed these files but I could not attach to the same Database Engine Server because I got an error.

View 1 Replies View Related

How To Make Copies Of Your Sql Database?

Jan 31, 2008

Hi,

at work all the databases i use are only accessible via the local network, i am wanting to take a copy of the databases and save them as a database file so i can burn them onto cd and take home with me so i can get some extra work done on the weekend (i'd also like to start doing this so i have backed up copies of the database incase anything happens to it)

i was wondering how i can do this? are there any tutorials on the web that someone can point me to? i have SQL Server 2005 Management Studio Express.

TIA

View 1 Replies View Related

Make A User For The Database

Nov 14, 2003

hi
how can i make a user give it a name ReportUser and a password msdn for a certain database named on the sql server 2000 and thank you for your help and oyur time

View 1 Replies View Related

How To Make Database Unavailable?

Apr 4, 2002

Hi!
Do you now if it is possible to make database unavailable for users after business hours and how.

Thank you in advance,
Elena.

View 6 Replies View Related

How Do I Make SQL Database Tables?

Nov 28, 2005

No, I don't need a step-by-step (necessarily). I've been looking at W3Schools tutorial and it says to:


Code:


CREATE TABLE Person
(
LastName varchar,
FirstName varchar,
Address varchar,
Age int
)



But what is that? A text file saved with a .sql extension. Something typed at a command prompt? Is there an SQL interface?

--William

View 5 Replies View Related

Looking To Make A Database Of Fingerprints

Jun 8, 2007

I work as a computer repair tech for my company and have been offered the opportunity to do a project. I'm looking to make a database of about 2000 peoples fingerprints (2 copies of each finger). We have Microsoft SQL Server but I have no Idea where to start. The vision is, to have an RFID scanner and have everyone swipe their badge then scan their prints and it automatically associates their prints with the badge number. Is there an easier or more simple way to do this or do you have any pointers on where to start? any help will be greatly appreciated. Thanks.:angel:

View 6 Replies View Related

How To Make Database For Reference

Jun 9, 2014

I am making a project where I have to add city, agentname, rankofagent, referenceagent name the problem is that who can I make a table where suppose I add member a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p like that

b is joined by a
c is joined by b
d by c, e by d and so on,

What I want here is that how can I get the result suppose i want to see that chain of p. I want result to be printed as a,b,c,d,e,f,g,h,i,j,k,l,m,n,o either result should be in horizontal form or vertical. with or without comma. I am doing this in SQL....

View 2 Replies View Related

How To Make Backup Of Database To URL

Aug 3, 2015

There is a need to make a backup of a database to URL. how to do this.

View 2 Replies View Related

Make Changes To A Production Database!

Jul 23, 2005

Hello faculties,We've a production database that is being used by one of our clientsas a backend for his website. The database size is around 1GB.Recently we added some tables to our local database which is areplica of the production database. Now we need to apply the samechanges at the production one aslo.I've no clue about what steps should i implement.Please guide me!Thanks in advanceDebian*** Sent via Developersdex http://www.developersdex.com ***

View 3 Replies View Related

Make Copy Of Database

Jan 8, 2008

Hi

I need to make a copy of a sql server database for test purposes but the database is live
how would i make a copy of it without it being affected?

thanks

View 4 Replies View Related

Get New Database Created Then Running Script To Created Tables / Relationships

Jun 29, 2015

trying to get a new database created then running a script to created the tables, relationships, indexes and insert default data. All this I'm making happen during the installation of my Windows application. I'm installing SQL 2012 Express as a prerequisite of my application and then opening a connection to that installed SQL Server using Windows Authentication. 

E.g.: Data Source=ComputerNameSQLEXPRESS;Initial Catalog=master;Integrated Security=SSPI; Then I run a query from my code to create the database eg: "CREATE DATABASE [MyDatabaseName]".

From this point I run a script using a Batch file containing "SQLCMD....... Myscriptname.sql". In my script I have my tables being created using "Use [MyDatabaseName]   Go   CREATE TABLE [dbo].[MyTableName] .....". So question is, should I have [dbo]. as part of my Create Table T-SQL commands? Can I remove "[dbo]."? Who would be the owner of the database? If I can remove the [dbo]., should I also remove dbo. from any query string from within my code?

View 3 Replies View Related

How To Make This Insert Data Into Sql Database

Dec 26, 2007

Hallow
My code does not insert Data into Database, please can someone look on it and give a technical problem over here please
It does not generate any error please, when I CLICK THE BUTTON IT DOES NOT GENERATE ERROR, IT GIVE ME THE MESSAGE THAT ITEM ADDED, BUT WHEN I LOOK MY TABLE NOTHING ID INSIDE Sub Add_To_Cart(ByVal Src As Object, ByVal Args As EventArgs)
 Dim FVProductID As Label = FormView1.FindControl("ProductID")
Dim FVProductName As Label = FormView1.FindControl("ProductName")Dim FVProductPrice As Label = FormView1.FindControl("ProductPrice")
 Dim DBConnection As SqlConnection Dim DBCommand As SqlCommand
Dim sql As String
Dim SQLAddString As String
 DBConnection = New SqlConnection("Data Source=MANDARISQLEXPRESS;Initial Catalog=SHOES;Integrated Security=True")
DBConnection.Open()
If Not Session("OrderID") Is Nothing Then
 sql = "SELECT Count(*) FROM ShoppingCart " & _ "WHERE OrderID = '" & CType(Session("OrderID"), String) & "' " _
& "AND ProductID = '" & FVProductID.Text & "'"
 DBCommand = New SqlCommand(sql, DBConnection)
 
If DBCommand.ExecuteScalar() = 0 Then
 SQLAddString = "INSERT INTO ShoppingCart (OrderID, ProductID, OrderDate, ProductName, ProductPrice, ProductQnty) VALUES (" & _
"'" & CType(Session("OrderID"), String) & "', " & _"'" & FVProductID.Text & "', " & _
"'" & Today() & "', " & _"'" & FVProductName.Text & "', " & _
"'" & FVProductPrice.Text & "', 1)"DBCommand = New SqlCommand(SQLAddString, DBConnection)
DBCommand.ExecuteNonQuery()
End If
End If
DBConnection.Close()
 
Src.Text = "Item Added"Src.ForeColor = Color.FromName("#990000") Src.BackColor = Color.FromName("#E0E0E0")
Src.Font.Bold = True
 
End Sub

View 3 Replies View Related

How To Make Database Accessible To User

Apr 12, 2008

I am setting up a web application, where the application needs to access a database. I have created the user (for the application) and it can log in to the SQL 2005 Sp2 server, but when I try to open the required database using Server Management Studio, it says "The database [name] is not accessible. (ObjectExplorer)"How do I make a database accessible to a login, using Server Management Studio?

View 2 Replies View Related

How To Make Database / Log Size Smaller

Apr 16, 2002

Hi all,

I found a database file and a log file over 2G on mssql 2000 server. Actually, they only need around 200M. I try to backup, truncate the database in order make the size smaller. But the size cannot be smaller. How can I do it?

Simon

View 3 Replies View Related

How To Make Genric Connection To SQL Database

Jun 16, 2003

I want to remove hard codings like below

servername.EcomAdminDB.dbo.tablename

to

ecom_link.dbo.tablename


I am using this in views

how we do it can somebody send me links on this ASAP.

View 2 Replies View Related

Make A Copy Of SQL Server Database

Mar 13, 2007

I'm trying to make a copy of our 2005 SQL Server production database (25 meg) so we can install it in a new office being set up in another state. I have right clicked on the database I want to copy, selected Tasks, then option Copy Database... I'm trying to put the copy on the same server, and I am doing this work signed into the Management Studio as "sa" The wizard creates 5 steps, the first 4 run ok, then the 5th step runs for 10 to 20 seconds, then quits. The message says to look in the log on the server for the reason it quit. The only log I can find is the Error Logs at the bottom of the Object Explorer window. I look into the current log, then select the SQL Server log, the current one. There is only one line in here about the copy I just tried, and it only says "Starting up database XXXXXXXX" which is the database I'm trying to create through the copy process. Within Database Mail, SQL Agent, and Windows NT log lines, I can not find any reference to the copy job that just bombed. Needless to say, I'm VERY new to all of this SQL Server admin stuff. If someone could point me in the right direction, it would really help! Thanks!

View 2 Replies View Related

Make Database Case Sensitive

Apr 25, 2007

How can I make my existing database case sensitive.
How to make SQL Queries also case sensitive from Application

ie:while running from VB,

Should work
rs.open"Select * from Employees"

Should Not work
rs.open"Select * from employees"
error should come as invalid table name.

View 8 Replies View Related

Make The Database Unavailable While Loading It

Jul 16, 2007

Hi All:I need to make my database unavailable when i am loading the db. Thishappens daily and the db is not connected to any online app, to makethe app unavailable. It is queried thru an Access and hence availableall the time.The load happens daily for an hour in the morning.Is there anyway to make it inaccessible to users while loading dataand then make it accessibleThank youRS

View 1 Replies View Related

How To Make New Database Sql Server 2005!

Aug 29, 2006

i had no problems working whith sql server 2000
but whith 2005 i am unable to make new database!
question : HOW?
respond asap

View 1 Replies View Related

How To Make A Single Database From Two Databases ....

Nov 8, 2006

Hi ...

I have two separete databases, what Ineed is that I want to make a single database of the two. Although all the table definitions of both the database are same.

I will be glad to know "how to make a single database from two" and i will be happy to see the query to insert the values from one database to another one.

Abdul Ghaffar

View 1 Replies View Related

Make A Database Record Read Only?

Oct 22, 2007



Hi.

I have a table where I need to set some rows to Read only (to protect the rows from being edited). Can I do this with a trigger checking against a column (where dataReadOnly = 1)?

Or is there a better way?

thankyou

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved