[ Pobierz całość w formacie PDF ]
.Withthese constraints in place, users of the database will not be able to make modifications to the data thatwould cause the data in one table to be out of sync with the data in the other tables.SummaryDesigning your database to conform to the relational model is important and can be difficult.Theprocess of designing a relational database is made easier by using the intuition-based R2D2s and thescience-based normal forms.The process of normalizing your database typically involves separatingtables in your database into more specialized tables.Use SQL Data Definition Language (DDL) to build the schema of your database, which includestables, indexes, and constraints.Indexes enable better query performance.Constraints help ensure theintegrity of the data inside the database.Q&AQ If I know my database stores data in 2KB pages, wouldn't it make sense tostructure my database tables so that each record is 2KB, also?A That approach would certainly optimize your database for speed.However, it would beimpossible to make such a database conform to the relational model.Your databasemight be marginally faster, but it would be incompatible with all the other databasesoftware and data access tools in the Universe.Your database would be a closed,proprietary system with no value outside your application.This ultimately would lessenthe value of your application.Q Is there a typical level of conformance to the relational model?A No.However, if your database conforms to the 3NF, you can be well assured of itsusability and its compatibility with relational data access tools.Q Do all relational database systems support the same DDL statements?A Support for DDL statements varies among relational database vendors.Check yourdatabase software documentation for specifics.Q Is it necessary to add constraints to my database?A Primary key constraints are necessary for a relational database to function reliably.Other constraints might not be necessary but are a great help to you in maintaining yourdatabase's value and usefulness.Rather than look for ways to avoid constraints, youshould look for places to use constraints wherever possible.They will protect theintegrity and validity of the information stored in your database.WorkshopThe Workshop quiz questions test your understanding of today's material.(The answers appear inAppendix F, "Answers.") The exercises encourage you to apply the information you learned today toreal-life situations.Quiz1.What is the highest normal form in the relational database model?2.What are entity relationships?3.How can you guarantee that a table conforms to the second normal form?4.What is the proper term for the structure (the tables, indexes, constraints, and so on) of arelational database?5.What does a referential integrity constraint do?Exercises1.Write a SELECT statement that shows all the products purchased on each order.Hint: TheSELECT statement should perform a join between the NewOrders, ProductsPurchased,and Products tables.2.Write a SELECT statement showing the products purchased by each customer.© Copyright, Sams Publishing.All rights reserved.Teach Yourself Database Programmingwith Visual C++ 6 in 21 daysWeek 1.In ReviewThe first day's lesson examines the different database technologies, including OLEstructured storage, record managers (such as Btrieve), desktop databases (such asFoxPro and Access), object databases, and relational database servers (such as Oracleand SQL Server).The lesson on Day 2 explains that the most widely used and accepted database model isthe relational model.A relational database consists of tables, which are arranged incolumns and rows.Each column is called a field.Each row is called a record and isunique, based on some key field or fields.The records in the tables in a relationaldatabase are related to each other, based on key fields that are called primary andforeign keys.In Day 3's lesson, you learned that SQL is a language that excels at manipulating data.You learned how to issue SELECT queries to retrieve records from a single table in arelational database.You learned how to perform joins to retrieve records from multipletables.You learned how to use sub-queries in SQL to obtain information that requires alarge quantity of procedural code to retrieve.Last, you learned that cursors are amechanism that enables record-at-a-time navigation through a result set.On Day 4, you learned that to access a database from C++, it's necessary to use adatabase API.Several database APIs are available to C++ developers.The future of alldata access in Microsoft Windows is OLE DB.The easiest way to use OLE DB is to useADO.ADO provides an object model that encapsulates the process of communicatingwith databases from within C++ programs, as well as from other programminglanguages.On Day 5, you learned two methods for manipulating records in a database.You learnedhow to manipulate records from C++ code by using the ADO Recordset memberfunctions to insert, update, and delete records.You also learned how to manipulaterecords from SQL, using the INSERT, UPDATE, and DELETE statements.On Day 6, you learned how to harness the power of relational database servers.You sawhow the SQL INSERT, UPDATE, and DELETE statements can be used to process manyrecords at a time.You also learned about stored procedures and how to call them, usingADO Command objects.You wrapped up your first week of study by learning how the process of designing arelational database can be made easier by using the intuition-based R2D2s and thescience-based normal forms.The process of normalizing your database typicallyinvolves separating tables in your database into more specialized tables.Use SQL DataDefinition Language (DDL) to build the schema of your database, which includestables, indexes, and constraints.Indexes can enable better query performance.Constraints can help ensure the integrity of the data inside the database.© Copyright, Sams Publishing.All rights reserved.Teach Yourself Database Programmingwith Visual C++ 6 in 21 daysWeek 2.At a GlanceThis week, you learn how to build real-world database applications.You exploremultitier architectures and Microsoft Transaction Server.You acquire a deeperunderstanding of relational database servers, COM, and Microsoftís database clientAPIs.Day 8 You discover the powerful innovations of relational database servers.Day 9 You acquire an understanding of the Component Object Model (COM)and write some COM software.Day 10 You learn Microsoftís database client technologies and learn how ADOuses COM.Day 11 You learn the tools to build multitier applications.Day 12 You explore Microsoft Transaction Server (MTS) and learn to build anduse MTS components.Day 13 You learn to combine object-oriented programming with relationaldatabases.Day 14 You learn the ODBC, DAO, and RDO database APIs.© Copyright, Sams Publishing.All rights reserved.Teach Yourself Database Programmingwith Visual C++ 6 in 21 daysDay 8Utilizing the Capabilities of Database ServersDatabase TransactionsSQL Transaction StatementsTriggers to Execute SQL Code AutomaticallySQL Aggregate FunctionsCOUNTMAX, MIN, SUM, and AVGAggregate Functions and the GROUP BY ClauseSQL ViewsSummaryQ&AWorkshopQuizExercisesRelational database servers include tools that provide incredible power for processing and presentinginformation.These tools can be highly valuable and productive for you in writing databaseapplications.However, the value-or even the existence-of these tools is often not readily apparent fromdatabase documentation.Today you will discover these relational database server power tools.Today you willUse transactions to ensure that complex operations execute reliably [ Pobierz caÅ‚ość w formacie PDF ]
zanotowane.pl doc.pisz.pl pdf.pisz.pl odbijak.htw.pl
.Withthese constraints in place, users of the database will not be able to make modifications to the data thatwould cause the data in one table to be out of sync with the data in the other tables.SummaryDesigning your database to conform to the relational model is important and can be difficult.Theprocess of designing a relational database is made easier by using the intuition-based R2D2s and thescience-based normal forms.The process of normalizing your database typically involves separatingtables in your database into more specialized tables.Use SQL Data Definition Language (DDL) to build the schema of your database, which includestables, indexes, and constraints.Indexes enable better query performance.Constraints help ensure theintegrity of the data inside the database.Q&AQ If I know my database stores data in 2KB pages, wouldn't it make sense tostructure my database tables so that each record is 2KB, also?A That approach would certainly optimize your database for speed.However, it would beimpossible to make such a database conform to the relational model.Your databasemight be marginally faster, but it would be incompatible with all the other databasesoftware and data access tools in the Universe.Your database would be a closed,proprietary system with no value outside your application.This ultimately would lessenthe value of your application.Q Is there a typical level of conformance to the relational model?A No.However, if your database conforms to the 3NF, you can be well assured of itsusability and its compatibility with relational data access tools.Q Do all relational database systems support the same DDL statements?A Support for DDL statements varies among relational database vendors.Check yourdatabase software documentation for specifics.Q Is it necessary to add constraints to my database?A Primary key constraints are necessary for a relational database to function reliably.Other constraints might not be necessary but are a great help to you in maintaining yourdatabase's value and usefulness.Rather than look for ways to avoid constraints, youshould look for places to use constraints wherever possible.They will protect theintegrity and validity of the information stored in your database.WorkshopThe Workshop quiz questions test your understanding of today's material.(The answers appear inAppendix F, "Answers.") The exercises encourage you to apply the information you learned today toreal-life situations.Quiz1.What is the highest normal form in the relational database model?2.What are entity relationships?3.How can you guarantee that a table conforms to the second normal form?4.What is the proper term for the structure (the tables, indexes, constraints, and so on) of arelational database?5.What does a referential integrity constraint do?Exercises1.Write a SELECT statement that shows all the products purchased on each order.Hint: TheSELECT statement should perform a join between the NewOrders, ProductsPurchased,and Products tables.2.Write a SELECT statement showing the products purchased by each customer.© Copyright, Sams Publishing.All rights reserved.Teach Yourself Database Programmingwith Visual C++ 6 in 21 daysWeek 1.In ReviewThe first day's lesson examines the different database technologies, including OLEstructured storage, record managers (such as Btrieve), desktop databases (such asFoxPro and Access), object databases, and relational database servers (such as Oracleand SQL Server).The lesson on Day 2 explains that the most widely used and accepted database model isthe relational model.A relational database consists of tables, which are arranged incolumns and rows.Each column is called a field.Each row is called a record and isunique, based on some key field or fields.The records in the tables in a relationaldatabase are related to each other, based on key fields that are called primary andforeign keys.In Day 3's lesson, you learned that SQL is a language that excels at manipulating data.You learned how to issue SELECT queries to retrieve records from a single table in arelational database.You learned how to perform joins to retrieve records from multipletables.You learned how to use sub-queries in SQL to obtain information that requires alarge quantity of procedural code to retrieve.Last, you learned that cursors are amechanism that enables record-at-a-time navigation through a result set.On Day 4, you learned that to access a database from C++, it's necessary to use adatabase API.Several database APIs are available to C++ developers.The future of alldata access in Microsoft Windows is OLE DB.The easiest way to use OLE DB is to useADO.ADO provides an object model that encapsulates the process of communicatingwith databases from within C++ programs, as well as from other programminglanguages.On Day 5, you learned two methods for manipulating records in a database.You learnedhow to manipulate records from C++ code by using the ADO Recordset memberfunctions to insert, update, and delete records.You also learned how to manipulaterecords from SQL, using the INSERT, UPDATE, and DELETE statements.On Day 6, you learned how to harness the power of relational database servers.You sawhow the SQL INSERT, UPDATE, and DELETE statements can be used to process manyrecords at a time.You also learned about stored procedures and how to call them, usingADO Command objects.You wrapped up your first week of study by learning how the process of designing arelational database can be made easier by using the intuition-based R2D2s and thescience-based normal forms.The process of normalizing your database typicallyinvolves separating tables in your database into more specialized tables.Use SQL DataDefinition Language (DDL) to build the schema of your database, which includestables, indexes, and constraints.Indexes can enable better query performance.Constraints can help ensure the integrity of the data inside the database.© Copyright, Sams Publishing.All rights reserved.Teach Yourself Database Programmingwith Visual C++ 6 in 21 daysWeek 2.At a GlanceThis week, you learn how to build real-world database applications.You exploremultitier architectures and Microsoft Transaction Server.You acquire a deeperunderstanding of relational database servers, COM, and Microsoftís database clientAPIs.Day 8 You discover the powerful innovations of relational database servers.Day 9 You acquire an understanding of the Component Object Model (COM)and write some COM software.Day 10 You learn Microsoftís database client technologies and learn how ADOuses COM.Day 11 You learn the tools to build multitier applications.Day 12 You explore Microsoft Transaction Server (MTS) and learn to build anduse MTS components.Day 13 You learn to combine object-oriented programming with relationaldatabases.Day 14 You learn the ODBC, DAO, and RDO database APIs.© Copyright, Sams Publishing.All rights reserved.Teach Yourself Database Programmingwith Visual C++ 6 in 21 daysDay 8Utilizing the Capabilities of Database ServersDatabase TransactionsSQL Transaction StatementsTriggers to Execute SQL Code AutomaticallySQL Aggregate FunctionsCOUNTMAX, MIN, SUM, and AVGAggregate Functions and the GROUP BY ClauseSQL ViewsSummaryQ&AWorkshopQuizExercisesRelational database servers include tools that provide incredible power for processing and presentinginformation.These tools can be highly valuable and productive for you in writing databaseapplications.However, the value-or even the existence-of these tools is often not readily apparent fromdatabase documentation.Today you will discover these relational database server power tools.Today you willUse transactions to ensure that complex operations execute reliably [ Pobierz caÅ‚ość w formacie PDF ]