Premium Essay

Join File

In:

Submitted By Darksapphire
Words 525
Pages 3
Jeremy Wallace
CIST1220
September 12, 2014
Chapter 10 Key Terms

Data Structure – A model of a database.
Entity – An object
Attribute – An item of information
Entity-Relationship (ER) Modeling – Used to model a database system after a real-world system
Instance – An occurrence of an entity
Linking Table - database table that contains common fields from two or more other database tables within the same database
Connecting Table – See Linking Table.
Associate Table – See Linking Table.
Computer-aided software engineering tool (CASE) – A tool to make the design process and complicated designs easier
Referential Integrity – Is when relationships between tables are maintained correctly
Declarative Referential Integrity (DRI) – When foreign key constraints are used to enforce referential integrity
Foreign Key Constraints – Prevents all of the operations that violate referential integrity
Triggers – A special type of procedure that can be used to determine if an operation would violate referential integrity
Orphaned Row – A row of a foreign key table that loses the relation to the row in a primary key table because the row is deleted
Update Anomaly – If the updated value of the foreign key does not have a matching primary key value in a related table
Insertion Anomaly – When inserting a row in the foreign key table, and the foreign key value does not have a matching primary key value in a related table
Deletion Anomaly – When deleting a row from the primary key table, and the foreign key table contains one or more rows related to the deleted row
Normalization – A formal process you can use to separate the data in a data structure into related tables
Data Redundancy – When storage space is wasted due to unnecessary repeating of data
Unnormalized Data Structure – A structure with tables that can contain information about two or more entities

Similar Documents

Premium Essay

Sbsehe

...Table Name : Employee EMPLOYEE _ID FIRST_NA ME LAST_NA ME SALA RY JOINING_D ATE DEPARTME NT 1 John Abraham 1000000 01-JAN-13 12.00.00 AM Banking 2 Michael Clarke 800000 01-JAN-13 12.00.00 AM Insurance 3 Roy Thomas 700000 01-FEB-13 12.00.00 AM Banking 4 Tom Jose 600000 01-FEB-13 12.00.00 AM Insurance 5 Jerry Pinto 650000 01-FEB-13 12.00.00 AM Insurance 6 Philip Mathew 750000 01-JAN-13 12.00.00 AM Services 7 TestName1 123 650000 01-JAN-13 12.00.00 AM Services 8 TestName2 Lname% 600000 01-FEB-13 12.00.00 AM Insurance Table Name : Incentives EMPLOYEE_REF_ID INCENTIVE_DATE INCENTIVE_AMOUNT 1 01-FEB-13 5000 2 01-FEB-13 3000 3 01-FEB-13 4000 1 01-JAN-13 4500 2 01-JAN-13 3500 SQL Queries Interview Questions and Answers on "SQL Select" 1. Get all employee details from the employee table Select * from employee 2. Get First_Name,Last_Name from employee table Select first_name, Last_Name from employee 3. Get First_Name from employee table using alias name “Employee Name” Select first_name Employee Name from employee 4. Get First_Name from employee table in upper case Select upper(FIRST_NAME) from EMPLOYEE 5. Get First_Name from employee table in lower case Select lower(FIRST_NAME) from EMPLOYEE 6. Get unique DEPARTMENT from employee table select...

Words: 4444 - Pages: 18

Premium Essay

Programming

...Which is not true about the USING keyword? A) you use it to simplify the syntax for joining tables B) you code a USING clause in addition to the ON clause C) it can be used with inner or outer joins D) the join must be an equijoin, meaning the equals operator is used to compare the two columns Points Earned: 0.0/2.0 Correct Answer(s): B Correct 2. When you code a SELECT statement, you must code the four main clauses in the following order A) SELECT, FROM, ORDER BY, WHERE B) SELECT, ORDER BY, FROM, WHERE C) SELECT, WHERE, ORDER BY, FROM D) SELECT, FROM, WHERE, ORDER BY Points Earned: 2.0/2.0 Correct Answer(s): D Correct 3. When coded in a WHERE clause, which search condition will return invoices when payment_date isn’t null and invoice_total is greater than or equal to $500? A) payment_date IS NULL AND invoice_total > 500 B) payment_date IS NOT NULL OR invoice_total >= 500 C) NOT (payment_date IS NULL AND invoice_total = 500 Points Earned: 2.0/2.0 Correct Answer(s): D Correct 4. The order of precedence for the logical operators in a WHERE clause is A) Not, And, Or B) And, Or, Not C) Or, And, Not D) Not, Or, And Points Earned: 2.0/2.0 Correct Answer(s): A Correct 5. Which of the following types of SQL statements is not a DML statement? A) INSERT B) UPDATE C) SELECT D) CREATE TABLE Points Earned: 2.0/2.0 Correct Answer(s): D Incorrect 6. Which of the following is not a common error when entering and...

Words: 1309 - Pages: 6

Premium Essay

Note

...In SQL, a join is used to compare and combine rows from two or more table. Inner Join: An inner join returns records only those records are common in both tables. Outer Join An outer join returns a set of records (or rows) that include what an inner join would return but also includes other rows for which no corresponding match is found in the other table. There are three types of outer joins: * Left Outer Join (or Left Join) * Right Outer Join (or Right Join) * Full Outer Join (or Full Join) Each of these outer joins refers to the part of the data that is being compared, combined, and returned. Sometimes nulls will be produced in this process as some data is shared while other data is not. Left Outer Join A left outer join will return all the data in Table 1 and all the shared data (so, the inner part of the Venn diagram example), but only corresponding data from Table 2, which is the right join. Right Outer Join A right outer join returns Table 2's data and all the shared data, but only corresponding data from Table 1, which is the left join. Full Outer Join A full outer join, or full join, which is not supported by the popular MySQL database management system, combines and returns all data from two or more tables, regardless of whether there is shared information. Think of a full join as simply duplicating all the specified information, but in one table, rather than multiple tables. Where matching data is missing, nulls will be produced. These...

Words: 288 - Pages: 2

Free Essay

Mist Mysql Queries

...Project 6 Required Queries: *  Create a query that includes at least two INNER JOINS (i.e. spans at least three tables), a search criteria, and orders the resulting data. * >select M.MID, M.MFName * >from MEMBER as M * >inner join LINEITEM as LI on LI.MID=M.MID * >inner join ITEM as I on I.IID=LI.IID * >inner join DVD as D on D.IID=I.IID; * This shows which members have checked out DVDs * Create a query that includes a calculation (e.g. average, sum, etc.). * >Select M.MID, M.MFName, count(B.IID) as “Books Checked Out” * >from MEMBER as M * >inner join LINEITEM as LI on LI.MID=M.MID * >inner join ITEM as I on I.IID=LI.IID * >inner join BOOK as B on B.IID=I.IID; * This query shows how many books a member has checked out * Create a query that includes at least one RIGHT or LEFT outer join. * >select MEMBER.MID, MEMBER.MFName, LIBRARIAN.LFName * >from MEMBER * >left outer join LINEITEM on LINEITEM.MID=MEMBER.MID * >left outer join LIBRARIAN on LINEITEM.LID=LIBRARIAN.LID * >order by MEMBER.MID; * This query uses a left join to show the relations between which librarians have checked out which members * Create a query that uses a GROUP BY to perform a calculation on information spanning at least two tables. * Create a query that includes a GROUP BY, but selects items from...

Words: 289 - Pages: 2

Free Essay

Outer Join and Scalar Queries

...and the number of sections that they have taught. Make sure to show the number of sections as 0 for instructors who have not taught any section. Your query should use an outer join, and should not use scalar subqueries. By using the university schema provided by db-book.com the following queries were done on the university database. The first query uses an outer join which works similar to the join operation but it keeps the rows that don’t match between the two tables that would be lost in a join operation. There are three forms of outer join: a) Left outer join displays the results from the left table even if the condition does not find any matching record in the right table. b) Right outer join will displays the results from the right table regardless if there is matching data in the left table. c) Full outer join will retain all rows from both tables, regardless if the data matches or not. The group by clause when used in a select statement collects data from multiple records and groups the results into one or more columns. The below is the query using left outer join operation: select ID, name, count(sec_id) as Number_of_sections from instructor natural left outer join teaches group by ID, name; The next query was written by using a scalar subquery without using an outer join operation. A scalar subquery is where the output of a subquery returns only one row which contains one single column/attribute. By using the select statement with count (*)...

Words: 414 - Pages: 2

Free Essay

Saaadfasfwaeraerasfasdfaesfasdfs

...name who are treated by Doctor Dr Bill. Sol.select p.fname,p.lname from patients p inner join doctors d on p.docid=d.doctorid where d.fname='dr.bill'; Q2. Find Patient Details occupied in room 1100. Sol.select p.patientid,p.fname,p.lname,p.address from patients p inner join room r on p.patientid=r.patientid where r.roomno=1100; Q3. Nurse Sue checked which all patients on 09-09-2015. Sol.select p.fname,p.lname from patients p where p.patientid in(select r.patientid from room r inner join nursecheckingdetails n on n.roomno=r.roomno where n.daate='09-09-2015'); Q4. List Names of Nurses who work with Dr Bill. Sol.select n.fname,n.lname from nurses n inner join doctors d on n.doctorid=d.doctorid and d.fname='dr.bill'; Q5. List Names of Doctors and number of patients they are treating or have treated. Sol.select d.fname as Doctorfname,d.lname as DoctorLName,count(p.patientid) as NoofPatients from patients p inner join doctors d on p.docid=d.doctorid group by d.fname,d.lname; Q6. List Names of Doctors and number of nurses they have with them to help. Sol.select d.fname as Doctorfname,d.lname as DoctorLname,count(n.nurseno) from doctors d left outer join nurses n on d.doctorid=n.doctorid group by d.fname,d.lname; Q7. How many rooms to type Basic are occupied? Sol.select count(r.roomno) as NoOfRooms from room r inner join roomdetails rd on r.typeofroom=rd.roomtypeid where rd.type='basic' and r.status='occupied'; ...

Words: 461 - Pages: 2

Free Essay

Joins in Sql

...Join in SQL SQL Join is used to fetch data from two or more tables, which is joined to appear as single set of data. SQL Join is used for combining column from two or more tables by using values common to both tables. JoinKeyword is used in SQL queries for joining two or more tables. Minimum required condition for joining table, is(n-1) where n, is number of tables. A table can also join to itself known as, Self Join. Types of Join The following are the types of JOIN that we can use in SQL. * Inner * Outer * Left * Right Cross JOIN or Cartesian Product This type of JOIN returns the cartesian product of rows from the tables in Join. It will return a table which consists of records which combines each row from the first table with each row of the second table. Cross JOIN Syntax is, SELECT column-name-list from table-name1 CROSS JOIN table-name2; Example of Cross JOIN The class table, ID | NAME | 1 | abhi | 2 | adam | 4 | alex | The class_info table, ID | Address | 1 | DELHI | 2 | MUMBAI | 3 | CHENNAI | Cross JOIN query will be, SELECT * from class, cross JOIN class_info; The result table will look like, ID | NAME | ID | Address | 1 | abhi | 1 | DELHI | 2 | adam | 1 | DELHI | 4 | alex | 1 | DELHI | 1 | abhi | 2 | MUMBAI | 2 | adam | 2 | MUMBAI | 4 | alex | 2 | MUMBAI | 1 | abhi | 3 | CHENNAI | ...

Words: 1005 - Pages: 5

Premium Essay

Data Base

... SELECT o.OrderID, n.ContactName, e.FirstName AS EmployeeFirstName, e.LastName AS EmployeeLastName, o.OrderDate FROM Orders o JOIN Employees e ON (e.EmployeeID = o.EmployeeID) JOIN Customers n ON (n.CustomerID = o.CustomerID) WHERE o.OrderDate > '1998-03-01' ORDER BY n.ContactName; 2. SELECT COUNT(DISTINCT Employees.EmployeeID) AS NumberOfEmployees, ISNULL(Employees.Country, 'None.') AS Country, COUNT(DISTINCT Customers.CustomerID) AS NumberOfCustomers, Customers.Country FROM Employees RIGHT JOIN Customers ON Employees.Country = Customers.Country GROUP BY Customers.Country, Employees.Country ORDER BY NumberOfEmployees DESC, NumberOfCustomers DESC; ΕΡΩΤΗΜΑ Δ 1. SELECT Address, Code, Country FROM Suppliers UNION SELECT Address, Code, Country FROM Customers UNION SELECT Address, Code, Country FROM Employees ORDER BY Country; 2. SELECT AVG(OD.Quantity) AS AverageQuantity, SUM(OD.Quantity * OD.UnitPrice) AS TotalOrderAmount, DATEDIFF(yy, e.BirthDate, e.HireDate) AS HireAge FROM [Order Details] OD JOIN Orders o ON ( OD.OrderID =O.OrderID) JOIN Employees E ON ( E.EmployeeID =O.EmployeeID) WHERE DATEDIFF(yy, e.BirthDate, e.HireDate) > = 30 GROUP BY DATEDIFF(yy, e.BirthDate, e.HireDate) ORDER BY DATEDIFF(yy, e.BirthDate, e.HireDate) DESC; ΕΡΩΤΗΜΑ Ε 1. SELECT o.ShippedDate, o.OrderDate FROM Orders o JOIN Suppliers sp ON (o.EmployeeID = sp.SupplierID) WHERE sp.CompanyName LIKE '%Pavlova%' ; 2. SELECT c.CompanyName,...

Words: 298 - Pages: 2

Free Essay

Enginerring Manager

...SELECT column_list FROM table-name  [WHERE Clause] [GROUP BY clause] [HAVING clause] [ORDER BY clause]; SELECT name, salary, salary*1.2 AS new_salary FROM employee  WHERE new_salary /salary*1.2 > 30000; SELECT first_name, last_name, subject  FROM student_details  WHERE subject IN/NOT IN ('Maths', 'Science');  Select * from product p  where EXISTS (select * from order_items o  where o.product_id = p.product_id) ------------------------------------------------- SELECT user.name, course.name ------------------------------------------------- FROM `user` ------------------------------------------------- RIGHT JOIN `course` on user.course = course.id SELECT name, salary FROM employee ORDER BY 1, 2; ELECT name, salary  FROM employee  ORDER BY name DESC, salary DESC; SELECT COUNT (DISTINCT name) FROM employee; HAVING Group functions (MAX,MIN) cannot be used in WHERE Clause but can be used in HAVING clause. SELECT dept, SUM (salary)  FROM employee  GROUP BY dept  HAVING SUM (salary) > 25000  INSERT INTO TABLE_NAME  [ (col1, col2, col3,...colN)]  VALUES (value1, value2, value3,...valueN); INSERT INTO employee (id, name, dept, age, salary location) SELECT emp_id, emp_name, dept, age, salary, location  FROM temp_employee; Copy data from A to B. Select first then insert If you are inserting data to all the columns, the above insert statement can also be written as, INSERT INTO employee  SELECT...

Words: 652 - Pages: 3

Free Essay

Test

...ALTER PROCEDURE [dbo].[ASP_Weekly_Lift_Report] @Voyage_Start Varchar(3) = Null, @Voyage_End Varchar(3) = Null, @Sales_Rep Varchar(25) = Null, @Service Varchar(4) = Null AS SET @Voyage_Start = IsNull(@Voyage_Start, '%') SET @Voyage_End = IsNull(@Voyage_End, '%') SET @Sales_Rep = IsNull(@Sales_Rep, '%') SET @Service = IsNull(@Service, '%') -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here SELECT dbo.tbl_Lift_Report_PayorList.[Rep Name], dbo.tbl_Lift_Report_PayorList.Parent, dbo.tbl_Lift_Report_PayorList.Business_Type, dbo.tbl_Lift_Report_PayorList.PayorID, dbo.tbl_Lift_Report_PayorList.Payor, dbo.tbl_Lift_Report_PayorList.[Payor Name - ID], dbo.tbl_Lift_Report_PayorList.[Booking Payor], dbo.tbl_Lift_Report_PayorList.ShipperID, dbo.tbl_Lift_Report_PayorList.Shipper, dbo.tbl_Lift_Report_PayorList.ConsigneeID, dbo.tbl_Lift_Report_PayorList.Consignee, dbo.tbl_Lift_Report_PayorList.[Service], dbo.tbl_Lift_Report_PayorList.[Svc Desc], dbo.tbl_Lift_Report_PayorList.Vessel, dbo.tbl_Lift_Report_PayorList.Voyage, dbo.tbl_Lift_Report_PayorList.[Voyage No], dbo.tbl_Lift_Report_PayorList.[Cargo Type], dbo.tbl_Lift_Report_PayorList.Booking, dbo.tbl_Lift_Report_PayorList.[Profit Year], dbo.tbl_Lift_Report_PayorList...

Words: 356 - Pages: 2

Free Essay

Estadistica

...Estándares Transact-SQL Buenas Prácticas de Programación 1. Convenciones y Estándares de Nombres Nota: Los términos “notación Pascal” y “notación de Camell” son usados a través de este documento. Notación Pascal – El primer carácter de todas las palabras se escribe en Mayúsculas y los otros caracteres en minúsculas. Ejemplo: ColorDeFondo Notación de Camell – El primer carácter de todas las palabras, excepto de la primera palabra se escribe en Mayúsculas y los otros caracteres en minúsculas. Ejemplo: colorDeFondo 1. Usa notación Pascal para el nombre de las Tablas CREATE TABLE dbo.Employee 2. Usa notación Pascal para el nombre de los campos de tabla CREATE TABLE dbo.Employee ( IdEmployee INT, FirstName VARCHAR(20), LastName VARCHAR(20) ) 3. NO usar nunca “sp_”, La razón es que: SQL Server reconoce el prefijo “sp_” como “System Stored Procedure”, es decir, un procedimiento almacenado de Sistema y lo buscaría en la Base de Datos. Usa la siguiente sintaxis para los nombres de los Stored procedures: Usp_<Nombre Esquema>_<Nombre Tabla> _<Accion> Ejemplo: usp_GEN_Employee_Insert usp_GEN_Employee_GetAll 4. Usa esquemas para agrupar los objetos como tablas, los nombres deben de ser Abreviados. Incorrecto: GEN_Employee Correcto: GEN.Employee 2. Consideraciones en el diseño de base de datos 1. El nombre de la base de datos debe de asemejarse al nombre de la aplicación, no deberá de contener...

Words: 2608 - Pages: 11

Free Essay

Database Management

...Written Assignment 3 Explain the SQL commands Union, Intersect, and Minus with concepts like union-compatibility, and syntax alternatives such as IN/NOT IN and various JOIN options Database Management CIS-311 There are many different SQL commands. This assignment will focus on UNION, INTERSECT, and MINUS. UNION combines unique rows returned by two SELECT statements. UNION ALL functions in the same way as UNION except that it also returns duplicates. INTERSECT gives you rows that are found in both queries by eliminating rows that are only found in one or the other. An INTERSECT is simply an inner join where we compare the tuples of one table with those of the other, and select those that appear in both while weeding out duplicates. MINUS returns the rows that are in the first query but not the second by removing the rows that are only found in the second query. There are three primary SQL commands involved when implementing a Union, Intersection and difference relational operators. As you may know, SQL data manipulation commands are set-oriented which are involved in operating over entire sets of rows and columns in tables at once. The UNION, INTERSECT, and MINUS statements make sure these operations occur. Union, Intersect and Minus only work properly if relations are Union-Compatible, which is based on the names of the relation attributes that must be the same and their data types must be alike. Being compatible does not mean the data types have to be exactly the...

Words: 673 - Pages: 3

Premium Essay

Dbms

...This document is provided in the hope that it is useful, but I can’t provide any assurance that any information it contains is in any way accurate or complete. Corrections or additions are welcome. Distribution Terms: This document is released into the public domain. Query Evaluation External Sorting • A DBMS frequently needs to sort data (e.g. for a merge-join, ORDER BY, GROUP BY, etc.) that exceeds the amount of main memory available. In order to do this, an external sort algorithm is used. • 2-Way External Merge Sort: – In the first pass, each page of the input relation is read into memory, sorted, and written out to disk. This creates N runs of 1 page each. – In each successive pass, each run is read into memory and merged with another run, then written out to disk. Since the number of runs is halved with every pass, this requires log2 N passes. Since an additional initial pass is required and each pass requires 2N I/Os, the total cost is: 2N( log2 N + 1) – Thus, we can see that the number of passes we need to make is critical to the overall performance of the sort (since in each pass, we read and write the entire file). Furthermore, the number of runs that we start with also determines the number of passes that are required. – This algorithm only requires 3 buffers: 2 input buffers (for the merging passes) and 1 output buffer. • Generalized Merge Sort: 1 – We usually have (far) more than 3 buffers available to use for sorting. If we have B buffers available, we...

Words: 12979 - Pages: 52

Free Essay

Aspects

...object-oriented programming is a way of modularizing common concerns. AspectJ is an implementation of aspect-oriented programming for Java A join point is a well-defined point in the program flow. A pointcut picks out certain join points and values at those points. A piece of advice is code that is executed when a join point is reached. These are the dynamic parts of AspectJ. AspectJ's aspect are the unit of modularity for crosscutting concerns. They behave somewhat like Java classes, but may also include pointcuts, advice and inter-type declarations. AspectJ provides for many kinds of join points, but this chapter discusses only one of them: method call join points. A method call join point encompasses the actions of an object receiving a method call. It includes all the actions that comprise a method call, starting after all arguments are evaluated up to and including return (either normally or by throwing an exception). when a particular method body executes execution(void Point.setX(int)) when a method is called call(void Point.setX(int)) when an exception handler executes handler(ArrayOutOfBoundsException) when the object currently executing (i.e. this) is of type SomeType this(SomeType) when the target object is of type SomeType target(SomeType) when the executing code belongs to class MyClass within(MyClass) when the join point is in the control flow of a call to a Test's no-argument main method cflow(call(void Test.main())) Pointcuts compose through...

Words: 876 - Pages: 4

Free Essay

Hurray

...PROCEDURES FOR CONDUCTING PRACTICAL ICT TESTS The Supervisor A suitably competent supervisor, who may be the candidates’ tutor, is responsible for the administration of the practical tests according to these instructions. The supervisor is responsible for the preparation of the hardware and software for the test. Timetabling of the Practical Tests CIE does not timetable the practical tests in the same way as most IGCSE and AS & A Level written papers. The IGCSE and AS & A Level timetable will specify a period within which candidates must take the two practical tests for each syllabus. Within this period, Centres may conduct the practical tests at any convenient time or times. Candidates must complete each practical test in a single session. Wherever possible, candidates from the same Centre should sit their assessment at the same time. If more than one session is necessary to accommodate all candidates, these sessions should follow on from each other. However, Centres do not need to sequester candidates until other candidates have taken the test. When arranging examination dates, Centres should take into account the time needed to set up the system and should allow contingency planning (e.g. to reschedule examination times due to possible hardware failure) wherever possible. Preparation for the Practical Tests Before the candidates take a practical test, the supervisor must work through a past/specimen paper, using the hardware and software that the candidates will be using...

Words: 2393 - Pages: 10