Database Modeling: Tables Flashcards
What is database modeling?
Developing a formal description of your DB, the schema, tables, columns, primary keys, relationships, etc. Don’t need fancy tools to do this; applies to any RDBMS; stay patient, methodical, step-by-step.
Name three important topics to consider when planning a database.
- What is this DB for? Get fairly specific here. Think hard about this.
- What do you already have? Gather all the physical assets; fix problems b4 putting them in the DB; create entities for what you already have: these will become the tables. Single word description of what you have.
- Think about vague relationships between the entities: an entity relationships (ER) diagram.
What are attributes and data types?
- Attributes - the columns in a table
- Data type for each column - get specific about the type of data: text, character, integer, binary (photo, video, audio, document), etc
When modeling a DB, is it better to be vague and flexible? Explain.
No. Define the columns as exactly as possible so the DB can enforce the rules. You do not want flexibility when planning and modeling relational DBs.
What do we do if we cannot find a natural primary key for a table?
You can have the DB create the key (surrogate) by adding an ID column. The DB can then be told to increment this value each time a row is added. A table should always have a primary key.
What is a composite key and when is it used?
A composite key is a primary key that is created by combining two or more columns. It is used when there is no natural primary key and you don’t want to use a surrogate (system-generated) key. Composite keys are often used with joining tables when creating many-to-many relationships.