c1.jpg beginning c# 2005 databases c# 2005 databases. published by. ... programmer to programmer,...

15
Beginning C# 2005 Databases Karli Watson

Upload: vonga

Post on 02-May-2018

221 views

Category:

Documents


2 download

TRANSCRIPT

  • BeginningC# 2005 Databases

    Karli Watson

    44063ffirs.qxd:WroxBeg 9/12/06 3:17 PM Page iii

    File AttachmentC1.jpg

  • 44063ffirs.qxd:WroxBeg 9/12/06 3:17 PM Page ii

  • BeginningC# 2005 Databases

    44063ffirs.qxd:WroxBeg 9/12/06 3:17 PM Page i

  • 44063ffirs.qxd:WroxBeg 9/12/06 3:17 PM Page ii

  • BeginningC# 2005 Databases

    Karli Watson

    44063ffirs.qxd:WroxBeg 9/12/06 3:17 PM Page iii

  • Beginning C# 2005 DatabasesPublished byWiley Publishing, Inc.10475 Crosspoint BoulevardIndianapolis, IN 46256www.wiley.com

    Copyright 2006 by Wiley Publishing, Inc., Indianapolis, Indiana

    Published simultaneously in Canada

    ISBN-13: 978-0-470-04406-3ISBN-10: 0-470-04406-3

    Manufactured in the United States of America

    10 9 8 7 6 5 4 3 2 1

    Library of Congress Cataloging-in-Publication Data:

    No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form orby any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permit-ted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior writtenpermission of the Publisher, or authorization through payment of the appropriate per-copy fee to theCopyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600.Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing,Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online athttp://www.wiley.com/go/permissions.

    LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHORMAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COM-PLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WAR-RANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULARPURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONALMATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOREVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHERIS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERV-ICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFES-SIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALLBE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION ORWEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OFFURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHERENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOM-MENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNETWEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHENTHIS WORK WAS WRITTEN AND WHEN IT IS READ.

    For general information on our other products and services please contact our Customer CareDepartment within the United States at (800) 762-2974, outside the United States at (317) 572-3993 orfax (317) 572-4002.

    Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and relatedtrade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, inthe United States and other countries, and may not be used without written permission. All othertrademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated withany product or vendor mentioned in this book.

    Wiley also publishes its books in a variety of electronic formats. Some content that appears in printmay not be available in electronic books.

    44063ffirs.qxd:WroxBeg 9/12/06 3:17 PM Page iv

    www.wiley.com

  • for donna

    44063ffirs.qxd:WroxBeg 9/12/06 3:17 PM Page v

  • 44063ffirs.qxd:WroxBeg 9/12/06 3:17 PM Page vi

  • About the AuthorKarli Watson is a freelance writer, developer, and editor and also the technical director of 3form Ltd.(www.3form.net). He started out with the intention of becoming a world-famous nanotechnologist, soperhaps one day you might recognize his name as he receives a Nobel Prize. For now, however, Karlismain academic interest is the .NET Framework and all the boxes of tricks it contains. Karli is also asnowboarding enthusiast, loves cooking, spends far too much time playing Anarchy Online, and wisheshe had a cat. As yet, nobody has seen fit to publish Karlis first novel, but the rejection letters make anattractive pile. If he ever puts anything up there, you can visit Karli online at www.karliwatson.com.

    44063ffirs.qxd:WroxBeg 9/12/06 3:17 PM Page vii

  • 44063ffirs.qxd:WroxBeg 9/12/06 3:17 PM Page viii

  • CreditsAcquisitions EditorKatie Mohr

    Development EditorMaryann Steinhart

    Technical EditorTodd Meister

    Additional MaterialDonna Watson

    Production EditorAngela Smith

    Copy EditorNancy Rapoport

    Editorial ManagerMary Beth Wakefield

    Production ManagerTim Tate

    Vice President and Executive Group PublisherRichard Swadley

    Vice President and Executive PublisherJoseph B. Wikert

    CompositorMaureen Forys, Happenstance Type-o-Rama

    ProofreadingJames BrookJennifer LarsenWord One

    IndexingJohnna VanHoose Dinse

    44063ffirs.qxd:WroxBeg 9/12/06 3:17 PM Page ix

  • 44063ffirs.qxd:WroxBeg 9/12/06 3:17 PM Page x

  • Acknowledgments

    Thanks to all at Wiley for helping me through this project and reining in my strange British stylings, to3form for giving me the time to write, to donna for keeping me sane, Funcom for providing a much-needed retreat, and to friends and family for being patient with my deadline-laden lifestyle.

    44063ffirs.qxd:WroxBeg 9/12/06 3:17 PM Page xi

  • 44063ffirs.qxd:WroxBeg 9/12/06 3:17 PM Page xii

  • Contents

    Acknowledgements xiIntroduction xix

    Chapter 1: Database Fundamentals 1

    What Is a Database? 2Relational Database Management Systems 3Object Oriented Database Management Systems 8

    Additional Features of RDBMSes 8Joins 9Functions 9Views 9Stored Procedures 10Triggers 10E-mail 10Indexes 11Security 11Concurrency Control 12Transactions 13Remote Access 13Backups 14Mirroring and Partitioning 14Management Tools 14

    What RDBMSes Are Available? 15MySQL and PostgreSQL 15DB2, Oracle, and SQL Server 16SQL Server 2005 Express Edition 16

    How Do You Use a Database? 17A SQL Primer 18XML 30

    Summary 33Exercises 34

    44063ftoc.qxd:WroxBeg 9/12/06 3:17 PM Page xiii