Beginning SQL
Beginning SQL Beginning SQL
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
- Page 70: you wish, and the database system d
- Page 74: A keyword is a word that has some m
- Page 78: Introduction to SQL A perfectly val
- Page 82: Data Type Description Storage Used
- Page 86: The char and varchar data types use
- Page 90: Most RDBMSs handle the most common
- Page 94: To add a new column, use the basic
- Page 98: Now that you know what you want to
- Page 102: ❑ Meeting date 2 ❑ Location 2
- Page 106: Generally speaking, picking a data
- Page 110: example, the MemberId field links t
- Page 114: Depending on which RDBMS you’re u
- Page 118: The FilmCategory table is very smal
- Page 124: Chapter 2 42 CategoryId Category 1
- Page 128: Chapter 2 44 Member First Last Date
- Page 132: Chapter 2 46 Now Steve’s record l
- Page 136: Chapter 2 This would work fine with
- Page 140: Chapter 2 If you want to delete all
- Page 146: 3 Extracting Information So far you
- Page 150: Returning Only Distinct Rows If you
- Page 154: The good news is that everything yo
- Page 158: MemberDetails (MemberId, FirstName,
- Page 162: MemberDetails table, the columns Fi
- Page 166: State DateOfJoining New State 2005-
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