SQL CHEAT SHEETRelational Database Concepts

SQL CHEAT SHEET Relational Database Concepts :




Within a relational database, data is stored in tables, and those tables consist of rows and columns, an arrangement that's easy to visualize. You might have columns for customer numbers, names, and addresses, for example. Each column represents a different type of data, and each row represents an individual data record. In this example, a row would have the customer number, name, and address of an individual customer.

The thing that makes a database relational is its use of foreign keys. For example, you might have a table of customer transactions named Orders, listing the items a customer ordered and when.


 You could store the customer's shipping information in that table as well, but if Mr. ABC orders from you a dozen times every month, you'd have his shipping information stored in the table many times over, which is wasteful. Instead, you could just store the customer number as a column in your Orders table, and keep Mr. ABC's address information in a separate, but related table, where you'd only have to store it once. The customer number in this case is the foreign key in the Orders table-it defines the relationship between the Orders table and the Customers table.



To read the data from a relational database, you use a query to define the data that you want to retrieve. In plain English, you'd say something like, "Get me the names of all the customers who live in Philadelphia." Of course, you need a formal way of relaying that instruction to the database, and that's where SQL comes in. SQL (pronounced "sequel") stands for "Structured Query Language," and gives you a way to define the queries. In SQL, the query we just mentioned might look like this:




SELECT Name FROM Customers WHERE City = "India"




Sql Server Interview Qus:



Comments

Popular posts from this blog