Creating Schema

Published 14 March 06 03:16 PM

One of the most basic tasks in Access is creating somewhere to put data - designing schema.  My goal for today was to run through the basic schema creation tools, and to leave the new "complex data" schema creation for next time, but in looking at the last post, much of the most basic ground was already covered, so we'll go further in this post and cover the complex data features as well. 

Schema from Datasheet

As described in the last post, Access 12 can create schema by example, where the user simply starts typing into a grid (the "datasheet") and we guess the data types automatically and the product just works.  This is simple for beginning users, and Access 12 does automatically create an ID column for each table, so there's a unique index for the table, and the user has something to build joins on as she gets more sophisticated.  The basic schema by datasheet experience looks like this:

The user simply starts typing in the header row to set column names, then types data in the rows below to fill-in her table.  Access guesses the data types as she does this.  For more details, please look at the Starting From Scratch post.

Table Templates

One of the key problems that new users have in Access is creating well-structured databases.  The tracking apps will help by creating normalized schemas for the most common applications, but many users will need to build their own databases without starting from the tracking apps.  Table Templates provide a way for users to get well-structured single tables that they can easily add to their own applications.  There's a simple entry point on the ribbon:

The entry provides a list of 5 basic common table types that the user can simply drop into her application and extend or use as is.  An example would be the Issues table, which looks like this:

 

The full list of fields is easier to see in the table designer:

SharePoint List Templates

Access 12 provides a set of templates for SharePoint lists similar to that for local tables.  This list is available from a button in the ribbon right next to the Table Templates:

It has a similar list of tables, with the exception of Custom (which creates a simple SharePoint list that you can then extend) and it also provides an alternate way to link to an existing SharePoint list.  Selecting one of these lists brings up a prompt for the appropriate server and a name for the list:

The schemas for these lists are similar to those for the local tables, the only difference being that the SharePoint lists are created on the server and linked to Access.

Field Templates

Users who want to create their own tables can still get help building well-structured fields (i.e. with appropriate data types and lengths) from the Field Templates.  Here the user selects the field templates button on the ribbon and gets a list of potential fields.  This list contains a set of generic fields, and then all the individual fields from the Table Templates above.  Click the image below to see the list of available fields for Issues. 

(Click image to enlarge)

The user then simply drags and drops the appropriate field into her table. 

(Click image to enlarge)

Lookup Fields and Complex Data

Access has supported "Lookup Fields" for several versions and has added power to the feature for Access 12 by allowing for multi-valued lookups.  Lookup fields are simply fields that present a different value in their control than they store in the table.  In the Issues example we've been using, "Assigned to" and "Opened by" are both lookups.  The Issues table stores the ID of the entry in the Contacts table, but whenever the user sees the Issues table, she sees the Contact Name rather than the number.  This is simply good database practice (normalized data, joined on unique identifiers), but made easy enough for non-developers.  The last post showed creating a normal lookup column using the Lookup Wizard.

Access 12 extends the lookup concept by enabling multi-valued lookups.  Where a lookup is really just a join made easy, a multi-valued lookup is simply a many-to-many join made easy.  In XML terms this would be represented as an optional repeating value, which is why we think of this internally as support for complex data.  SharePoint uses these data structures in a number of places (e.g. support for multiple attachments for each item in a list), so Access needed to add similar support to provide schema symmetry, but the concept is broadly useful outside the context of SharePoint.  In our Issues example, the user may want to assign an issue to more than one person.  This was do-able before, but required a lot of work (building the join table, setting up the relationships) and a lot of knowledge (i.e. how to build the join table, etc.).  The Lookup Wizard now does all this for the user.

The user simply starts by clicking the Lookup Column button on the ribbon (with a column selected in the datasheet):

(Click image to enlarge)

Then she goes through the wizard as she did before:

(I skipped a couple of steps here, since they're the same as the ones shown before.)  On the last pane of the wizard, she selects "Allow Multiple Values" and hits finish.  This automatically builds (and hides) the join table and sets up the relationships, so the experience is just the same as for a standard lookup. 

The key difference, though, is that the user can now select multiple people in the Assigned to column:

Next Time

The next post is a little up in the air.  I'll hopefully be able to talk about the new Ribbon UI.  However, we're doing some polish on how the UI is laid out and I'd like to be done before I explain how the whole thing works, so I don't then have to explain why it is all changed!  We're pretty close to nailing that down, so hopefully next week I'll be able to describe it all.  If not then, the week after.  If I can't talk about the ribbon, I'll cover the new report designer, which is super cool too.

Comments

# Cyrus Bernstead said on March 15, 2006 12:08 AM:

The many-to-many feature (including the multi-select combobox) looks great.  I think many developers - myself included - will find an immediate use for it.

Am I safe in assuming that the automatically created join table can be unhidden and be viewed/edited like a normal table?

# Ken said on March 15, 2006 10:18 AM:
1a.  The plural of schema is schemata or schemas.
1b.  Why do you assume all Access programmers are female?

2.  Does the many-many feature apply to ADPs?

3.  What happens if the many-many lookup table has 1 million rows?  How will it perform?  Can it use a lookup combo box instead of a checklist?  How will such a combobox or list of checkboxes perform with large numbers of possible entries?

For example: Customer<-->Purchased product

I would guess this is too hard for the wizard to handle?

# Step said on March 15, 2006 12:06 PM:
This is pretty exciting, and very welcomed!  I assume, as Cyrus does, that we can unhide and view the join table.  Please confirm this.  

I'm also looking forward to seeing more of what you've done with the report designer.  The little I've heard so far sounds awesome!
# Stevbe said on March 16, 2006 8:12 AM:
Are there any changes to the table designer, field data types and properties, relationships, indexes ... you know REAL schema stuff that us non-users are interested in? Any new wizard that will create a DDL script based on the tables already in a database? Does Access SQL fully support all elements of schema that you can do through the UI?

Is the multi-select listbox with checkboxes a new control that we can use on forms?

While lookups sound like a good idea on the surface and wizards make it all feel groovy can you respond to the issues presented here?
http://www.mvps.org/access/lookupfields.htm

Thanks,
# Erik Rucker said on March 16, 2006 4:18 PM:
This is a bit of a consolidated reply.  The current plan is for the join table not to be unhideable, simply because it is not very user friendly (e.g. its name is a GUID) and it is work to make it understandable.  We could make it unhideable (like the system tables) but probably can't afford to make it easy to read.  

The many-to-many features don't work in ADP's because there's no analogue to the feature in SQL.  Of course you could build the same thing in SQL, but you'd have to write a bunch of stuff.

What are the new data types in Access 12 and what other schema related tools are there.  There are a couple of new data types - principally Attachments (which matches SharePoint and uses the many-to-many work) and Rich Text (this is a property on a memo field, the data is still text, but it is always shown in a rich text control with formatting).  No significant new work on indexes, etc.  Yes, the multi select listbox is available on forms, for complex data fields.  Lookups in general are old, old Access features, and this isn't the best place to run though all the details.  The short version is like most things, there are things they do better and things they do worse.  We believe they're a valuable feature but understand there's room for improvement.

One final (hopefully) lighthearted question.  Why all the women Access developers in my examples?  Both typing and reading "he or she" is just awkward, and always having the examples be men just seems wrong, so I try to change it up.  
# Stevbe said on March 17, 2006 8:22 AM:
If the multi-value schema is hidden then it can't be extended so as a developer I can't see using this. If it is used and then needs to be extended by creating schema manually how do you get to the old data for conversion?

I didn't get your answer on the multi-select checked listbox. Is this a seperate control that I can use in a way that has nothing to do with being bound to a complex data field? An example would be that I want to enable users to select multiple departments as criteria for a report, where the dept is a 1-M in the schema. The checked multi-select listbox looks/feels better than the standard multi-select listbox.

Is the Attachment data type just a BLOB without the overhead of OLE Object?

Thanks,
Steve
# Clint Covington said on March 17, 2006 9:34 AM:
>> If the multi-value schema is hidden then it can't be extended so as a developer I can't see using this.

Developers can extend it through DAO. It is exposed as a recordset on the field. You can also get to the data using queries. You will have to write a little code to convert an old m-m junction to use complex data. If you want to extract the data from the junction table it is a pretty simple make/append table query.

The multiselect list box is only available when it is bound to a complex data field. We have looked at making it available more generically but that likely won't happen this release. There certianly is some value here.

The attachment stores data in a binary field. It doesn't have the overhead of OLE Objects. Additionally, we do some compression and uncompression on the field to keep the database small.

Clint
# Stevbe said on March 17, 2006 1:42 PM:
I want to start off by saying I like Access and enjoy making a living developing with it. It beats the heck out of any other language for building data aware applications (yes, including all the new stuff in .NET 2.0). It must be difficult to strike the right balance between ease of use and development flexibility. The easier you make it to use, the easier it is for users to build something poorly. Part of making it easier is hiding things like the complex data structures. The easier it is to create a poor design and the more that is hidden makes it difficult for developers. The more power you put into it makes it even easier for users to do bad things. Then you get developers criticizing your implementation and clamoring for more.

Back to the post ...

>>Of course you could build the same thing in SQL, but you'd have to write a bunch of stuff.
So the upsize wizrd will choke on this?


>>Developers can extend it through DAO

I am thinking that a Due Date would be a good field to add for each person record assigned but if the table is hidden then how do I get its GUID name to Set a TableDef in order to add this field? And when I do get this figured out, does the check listbox display the new field? Is there a way to control what fields are displayed, is there any control over formatting, fonts etc? Can the extension be done with ADOX and/or SQL DDL?


>>If you want to extract the data from the junction table it is a pretty simple make/append table query.

Same base point as previous ... where do I get the GUID table name?

While I accept that it can be done it sounds like more work to back out or extend what the wizard has done than if I did it myself in the first place.


>>The multiselect list box is only available when it is bound to a complex data field.

This is the kind of thing that drives developers crazy. Users get use to how a multi-select list works with check boxes but everywhere else in the app we have to use regular multi-selects.  This creates an inherent conflict in the UI. While I could rework what the wizrd created to make things constitant they still want the check box which I can't provide.

Eagerly waiting for news about developer enhancements,
Steve
# JeremyNYC said on March 17, 2006 3:43 PM:
Yikes! I'm in full agreement here, most importantly with the notions that the mixed metaphor for picking multiple values is a really bad idea and that hiding these tables and giving the GUIDs for names is going to make taking over Access projects gone awry (a big portion of independent Access developers' income) much more difficult.

Jeremy
# RM said on March 17, 2006 5:55 PM:
RE the last few posts:

I have created a generic approach to adding many-many records using a checkbox to insert records into the middle (joining) table.  It's not really that difficult to use for generic many-many situations when the lookup table is less than about 10,000 records.  I wi=onder if you could ever use the new wizard to function with 10,000 records.

Given the drawbacks of the wizard's many-many approach, I doubt that I will ever use it (especially since I generally only use ADPs.)  So far, it seems like it's designed for novices only.

The real difficulty is when you have a million records on the lookup side of the join.  There is no great way to get around this kind of performance problem other than using a pop-up form where users can search for the exact records they need, and then use a bit of VBA to make the join manually.  I would like a lookup checkbox list that automatically requeried the database for the TOP X records after the user types in a few characters.  Then you could use any size lookup table and not bog down the both the client and the server.  In fact, I have implemented a solution like this in code, but I would prefer a built-in solution to this problem.
# Erik Rucker said on March 23, 2006 3:42 PM:
Another consolidated response.  

The complex data features will not upsize to SQL Server without changes, but they will move to SharePoint just fine.  The challenge here is the underlying difference between the 2 platforms.  Complex fields upsized to SQL will show up as delimited text.  

How do I get the hidden table name for complex data to go against it programmatically.  We're working on doing better here and will have more to report soon.

Why no multi-checkbox list control outside complex data.  Yes, we understand the issue here and I appologize that it isn't there.  We just couldn't fit in the work.  The traditional control is still available and is well understood by users, but I do understand why you'd like the new one.  Again, sorry.
# A discussion of what's new in Access 12 said on April 25, 2006 5:56 PM:
Building modern looking data forms &amp;amp; reports in Access 2003 can be difficult.&amp;nbsp; Doing the heavy...
# Tim Ellison said on October 30, 2006 8:28 PM:

Great write up.  We're using linked tables in Access as intermediary staging repositories for list management (using of course, SSIS).

I have one question regarding multi-value lookups.  I tried the old string sequence (from 2003) of #;~n~#; to store the IDs from the "master" list, and although I get no errors from the ETL, it doesn't appear that the values are set.  Additionally, if I include the field in a view of the list, MOSS blows chunks.  Has the string sequence changed between 2003 and 2007 versions?

Thanks.

# Dating said on May 31, 2008 10:18 PM:

One of the most basic tasks in Access is creating somewhere to put data - designing schema. My goal for today was to run through the basic schema creation tools, and to leave the new &quot;complex data&quot; schema creation for next time, but in looking

# Weddings said on June 5, 2008 8:51 AM:

One of the most basic tasks in Access is creating somewhere to put data - designing schema. My goal for today was to run through the basic schema creation tools, and to leave the new &quot;complex data&quot; schema creation for next time, but in looking

New Comments to this post are disabled
Page view tracker