Beginning SQL

Beginning SQL Beginning SQL

marjan.fesb.hr
from marjan.fesb.hr More from this publisher
20.07.2013 Views

Chapter 1 ❑ Databases are part of a larger software application called a database management system (DBMS). ❑ SQL is a declarative programming language, that is, you use it to specify the answers you want and leave the DBMS to work out how to get them. After getting the basics under your belt, you got down to some practical work. In particular, you created a database and learned the basics of SQL and table creation. In doing so, you found out the following: ❑ How databases are organized. You saw that databases are composed of tables, which themselves are composed of records, and that each record is split into fields or columns. ❑ How to create a database. You learned that you can create a database either with the RDBMS’s management tools or with SQL statements. ❑ Different types of data are stored differently. You learned that databases support a number of different data types for storing text (char and varchar), numbers (integer, real, and decimal), and time and dates (time and date). These are just the basic data types, and most RDBMSs support many more data types. ❑ The principles of good database design. Finally, at the end of the chapter, you created the book’s example database using the techniques and code covered earlier in the chapter. In the next chapter, you learn how to add, update, and delete data using SQL. Don’t forget to have a go at the exercises! Exercises 1. As it happens, the film club holds meetings regularly in several different locations, which means a lot of redundancy in the Attendance table. What changes could you make to the database table structure? 2. Write the necessary SQL to complete the changes required by Exercise 1 and at the same time split the location’s address details into street, city, and state. 40

Chapter 1<br />

❑ Databases are part of a larger software application called a database management system (DBMS).<br />

❑ <strong>SQL</strong> is a declarative programming language, that is, you use it to specify the answers you want<br />

and leave the DBMS to work out how to get them.<br />

After getting the basics under your belt, you got down to some practical work. In particular, you created<br />

a database and learned the basics of <strong>SQL</strong> and table creation. In doing so, you found out the following:<br />

❑ How databases are organized. You saw that databases are composed of tables, which themselves<br />

are composed of records, and that each record is split into fields or columns.<br />

❑ How to create a database. You learned that you can create a database either with the RDBMS’s<br />

management tools or with <strong>SQL</strong> statements.<br />

❑ Different types of data are stored differently. You learned that databases support a number<br />

of different data types for storing text (char and varchar), numbers (integer, real, and<br />

decimal), and time and dates (time and date). These are just the basic data types, and<br />

most RDBMSs support many more data types.<br />

❑ The principles of good database design.<br />

Finally, at the end of the chapter, you created the book’s example database using the techniques and<br />

code covered earlier in the chapter. In the next chapter, you learn how to add, update, and delete data<br />

using <strong>SQL</strong>. Don’t forget to have a go at the exercises!<br />

Exercises<br />

1. As it happens, the film club holds meetings regularly in several different locations, which means<br />

a lot of redundancy in the Attendance table. What changes could you make to the database table<br />

structure?<br />

2. Write the necessary <strong>SQL</strong> to complete the changes required by Exercise 1 and at the same time<br />

split the location’s address details into street, city, and state.<br />

40

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!