27
Lecture 5 Lecture 5 Relational Databases and Relational Databases and going multiuser going multiuser

Lecture 5 Relational Databases and going multiuser

Embed Size (px)

Citation preview

Lecture 5Lecture 5

Relational Databases and going Relational Databases and going multiusermultiuser

AdministrativeAdministrative

For last lecture:For last lecture:– Explore new technology (web enabled Explore new technology (web enabled

technology)technology)– Discuss existing technology (How Delta’s Discuss existing technology (How Delta’s

databases are currently set up)databases are currently set up) Finally, got demo copy of FMPRO5 – try to Finally, got demo copy of FMPRO5 – try to

point out differences where I find them.point out differences where I find them. Optional test and certification?Optional test and certification?

ReviewReview

What are scripts used forWhat are scripts used for Designing scripts (before coding)Designing scripts (before coding) How to define scriptsHow to define scripts Most useful script stepsMost useful script steps TemplatesTemplates

Questions?Questions?

Any Questions from last lecture?Any Questions from last lecture?

TopicsTopics

What’s a relational database good for?What’s a relational database good for? Breaking it up.Breaking it up. Implementing relational db’s in FileMakerImplementing relational db’s in FileMaker Basic Multi-user and Security issuesBasic Multi-user and Security issues Tips for working in groupsTips for working in groups

Relational DB IntroRelational DB Intro

What is a relationship, and why is it necessaryWhat is a relationship, and why is it necessary Metaphor: Think of yourself vs. a day in your lifeMetaphor: Think of yourself vs. a day in your life

– You yourself have attributes (DOB, Height, etc)You yourself have attributes (DOB, Height, etc)– A day has certain attributes (traffic jam on I-80, Sunny A day has certain attributes (traffic jam on I-80, Sunny

day, etc) It contains some similarities between your day, etc) It contains some similarities between your day and other days, and some individual experiencesday and other days, and some individual experiences

– The relational part happens at the intersection between The relational part happens at the intersection between you and your day.you and your day.

– This can be seen as a “contains a” relationship, since a This can be seen as a “contains a” relationship, since a day contains people, one of which is you.day contains people, one of which is you.

– This relationship actually goes both ways, because in This relationship actually goes both ways, because in your “memory field” it will contain many of your days. your “memory field” it will contain many of your days. But you access is limited to what happened to youBut you access is limited to what happened to you

Relational DB IntroRelational DB Intro

Real world exampleReal world example Think of a furniture store database system:Think of a furniture store database system:

– Shipping information in one Db(address etc)Shipping information in one Db(address etc)– Transaction information in another (e.g. print receipts)Transaction information in another (e.g. print receipts)– Furniture information in another(price, number etc)Furniture information in another(price, number etc)– Possibly even employee information to link to receipts.Possibly even employee information to link to receipts.

Relational DB are called tables in some other DB Relational DB are called tables in some other DB systemssystems– In Microsoft Access you would use tables for many of In Microsoft Access you would use tables for many of

these thingsthese things

Deciding when to breakDeciding when to break

Deciding when to break upDeciding when to break up– First figure out if you have any “contains a” First figure out if you have any “contains a”

relationshipsrelationships– These are your candidatesThese are your candidates– If you’re database is extremely simple or you If you’re database is extremely simple or you

are using your db for only one function (e.g. are using your db for only one function (e.g. printing receipts)printing receipts)

– Otherwise you should strongly consider Otherwise you should strongly consider breaking it up.breaking it up.

Deciding when to breakDeciding when to break

Once you’ve decided to break it up you Once you’ve decided to break it up you have two options regarding the way to do have two options regarding the way to do lookups:lookups:– By Value, which means to copy the information By Value, which means to copy the information

from one database to the other (if you do this from one database to the other (if you do this changes in one db will not effect the other)changes in one db will not effect the other)

– By Reference, which essentially means to put By Reference, which essentially means to put the fields from one database directly into the the fields from one database directly into the other.other.

Value or Reference?Value or Reference?

Examples:Examples: Value:Value:

– This is good if for example you are storing receipts (or This is good if for example you are storing receipts (or forms), the majority of the information should be forms), the majority of the information should be copied in from your other sources, because you would copied in from your other sources, because you would not want your price info changingnot want your price info changing

Reference:Reference:– If you have a real-time inventory you would want to do If you have a real-time inventory you would want to do

that with references so you could update the that with references so you could update the information as it changed.information as it changed.

Key FieldKey Field

Usually we’ll use what’s known as a key Usually we’ll use what’s known as a key field to connect two databases, this will field to connect two databases, this will uniquely identify records, and could be for uniquely identify records, and could be for example a social security number.example a social security number.

You will always want a unique field so if You will always want a unique field so if you don’t have one make it, either use a you don’t have one make it, either use a caluculation and combine two fields, or use caluculation and combine two fields, or use the serial number function under autoentrythe serial number function under autoentry

ImplementationImplementation

First we need to define the relationshipsFirst we need to define the relationships– Go to File…Define Relationships(FMPRO5) or Go to File…Define Relationships(FMPRO5) or

File…Define…Define Relationships(FMPRO4)File…Define…Define Relationships(FMPRO4)– The following Screen will appearThe following Screen will appear

ImplementationImplementation

Click the New button, you will be presented Click the New button, you will be presented with a database, select the file you want to with a database, select the file you want to relate to this one.relate to this one.

Now you will be presented with this screen:Now you will be presented with this screen: Relate the key fieldRelate the key field

from DB2 with thefrom DB2 with thelookup field fromlookup field fromDB1DB1

ImplementationImplementation

Click the New button, you will be presented Click the New button, you will be presented with a database, select the file you want to with a database, select the file you want to relate to this one.relate to this one.

Now you will be presented with this screen:Now you will be presented with this screen: Relate the key fieldRelate the key field

from DB2 with thefrom DB2 with thelookup field fromlookup field fromDB1DB1

ImplementationImplementation

Don’t worry too much about the options on this Don’t worry too much about the options on this screen (I.e. create related record) the only one you screen (I.e. create related record) the only one you may want to look at at this stage is the sort related may want to look at at this stage is the sort related records, this sorts the output from a relationshiprecords, this sorts the output from a relationship

Now that you’ve made a relationship we can use it Now that you’ve made a relationship we can use it for Value or reference lookups, let’s try by Value for Value or reference lookups, let’s try by Value firstfirst– Under the auto-entry screen you may have seen a Under the auto-entry screen you may have seen a

checkbox that says looked-up value, simply click on checkbox that says looked-up value, simply click on that box and then select the name of your relationship that box and then select the name of your relationship from the screen that pop’s upfrom the screen that pop’s up

ImplementationImplementation

– Select the same field for both (I.e. both Name)Select the same field for both (I.e. both Name)– DON’T do this for the field that you used in the DON’T do this for the field that you used in the

relationship, this must remain as a normal field so that relationship, this must remain as a normal field so that when you type in the (I.e. SS#) the lookup will appear when you type in the (I.e. SS#) the lookup will appear on the related fields(name etc)on the related fields(name etc)

– Now we can finally see where repeating fields become Now we can finally see where repeating fields become handy.handy.

– Click on repetitions on the bottom of the autoenter Click on repetitions on the bottom of the autoenter screen(FMPRO4) or in the storage tab(FMPRO5)screen(FMPRO4) or in the storage tab(FMPRO5)

– Now click on the field on the layout go to Format…Now click on the field on the layout go to Format…Field Format type in the number of repetitions of the Field Format type in the number of repetitions of the field you want to displayfield you want to display

ImplementationImplementation

– What you’ve just done is perfect for an invoice What you’ve just done is perfect for an invoice or receipt because you could type in a part or receipt because you could type in a part number and have the price come up from the number and have the price come up from the related database, but that would not be changed related database, but that would not be changed if the price goes down.if the price goes down.

Now let’s look at referencesNow let’s look at references– A good example of this wanted to display how A good example of this wanted to display how

many of an inventory item were in stock or many of an inventory item were in stock or maybe for displaying a students contact info on maybe for displaying a students contact info on an invoicean invoice

ImplementationImplementation

– You can put referential fields directly in your layout, You can put referential fields directly in your layout, simply use the field tool like usual, except when it simply use the field tool like usual, except when it prompts you for the field, pull down the top menu to prompts you for the field, pull down the top menu to find your relationship, then choose the related fieldfind your relationship, then choose the related field

– This works fine for things thatThis works fine for things thatare unique(I.e. lookup theare unique(I.e. lookup theaddress from the student DB)address from the student DB)

– If instead you are looking forIf instead you are looking forsomething with more than onesomething with more than onerepetition (I.e. all the classes the repetition (I.e. all the classes the student has taken, you will needstudent has taken, you will needto do something elseto do something else

ImplementationImplementation

– You need to use a portal to display more than You need to use a portal to display more than one record on the same screenone record on the same screen

– The portal tool looks like this: The portal tool looks like this: and is next to the button tooland is next to the button tool

– Simply drag it out to display an area, than drag Simply drag it out to display an area, than drag in the fields you defined abovein the fields you defined above

– The portal looks likeThe portal looks likethisthis

– Make sure and drag into the top white sectionMake sure and drag into the top white section

Multi UserMulti User

Because it may be helpful for the project I’ll Because it may be helpful for the project I’ll discuss what you will need to do to set up discuss what you will need to do to set up your database so it can be worked upon in your database so it can be worked upon in multiple locations at oncemultiple locations at once– One caveat you can not define fields once your One caveat you can not define fields once your

db is set up for multi-user, so define these first.db is set up for multi-user, so define these first.– First go to Edit…Preferences…Application First go to Edit…Preferences…Application

then make sure under network protocol it says then make sure under network protocol it says TCP/IP if not select itTCP/IP if not select it

Multi UserMulti User

– Now go to file…sharing and select multi-userNow go to file…sharing and select multi-user– Now would be a good time to set up a password, go to Now would be a good time to set up a password, go to

File…Access Privileges…PasswordFile…Access Privileges…Password– The following screen will appear:The following screen will appear:– Type in aType in a

password andpassword andhit create tohit create topasswordpasswordprotect yourprotect yourfile. Don’t worryfile. Don’t worryabout everythingabout everythingelse for nowelse for now

Multi UserMulti User

– In order for both users to use it it has to be open In order for both users to use it it has to be open on one computer, then to log in the other user on one computer, then to log in the other user just clicks on File…open and then clicks on the just clicks on File…open and then clicks on the hosts button, somewhere in the list that appears hosts button, somewhere in the list that appears should be the name of the file click open and should be the name of the file click open and type in the password. Now both users can type in the password. Now both users can change the layout, modify scripts etc (except change the layout, modify scripts etc (except for fields of course)for fields of course)

GroupsGroups

Working in groups allows for complicated Working in groups allows for complicated databases to be designed in the minimal amount of databases to be designed in the minimal amount of timetime

Group work is also good for learning because it Group work is also good for learning because it allows students to learn from each otherallows students to learn from each other

There are many different approaches to working in There are many different approaches to working in groups I will present two and the method I would groups I will present two and the method I would prefer for you to take on this projectprefer for you to take on this project– The expert approach: in this approach each person The expert approach: in this approach each person

either is or becomes an expert in a specific area (e.g. either is or becomes an expert in a specific area (e.g. layouts, scripts etc) this approach has several layouts, scripts etc) this approach has several advantages advantages

GroupsGroups

– The advantages of the expert approach: minimal amount The advantages of the expert approach: minimal amount of time learning with maximal overall knowledge, great of time learning with maximal overall knowledge, great for getting a project done quickly, but does have some for getting a project done quickly, but does have some disadvantages this technique is often used in industry disadvantages this technique is often used in industry (and even here in our computer services department (and even here in our computer services department because of those advantages)because of those advantages)

– First and most important for this class is that you don’t First and most important for this class is that you don’t learn everything about the database system which leads learn everything about the database system which leads to the next problem, you can have concurrency to the next problem, you can have concurrency problems, if one person is not doing there job it could problems, if one person is not doing there job it could hold up another person from doing their job.hold up another person from doing their job.

GroupsGroups

– The technique I would like you to use is what I The technique I would like you to use is what I call the 80/20 group distributioncall the 80/20 group distribution

– If one person is or wants to be an expert in one If one person is or wants to be an expert in one area (e.g. scripts) they should do 80% of the area (e.g. scripts) they should do 80% of the work in this area, the other 20% should be done work in this area, the other 20% should be done by the other member(s)by the other member(s)

– This allows for the project to be completed This allows for the project to be completed relatively quickly while everyone gets a chance relatively quickly while everyone gets a chance to learnto learn

GroupsGroups

– Finally, I would recommend starting work the following Finally, I would recommend starting work the following way, before you start working with FileMaker at all way, before you start working with FileMaker at all write out everything you want to do on paperwrite out everything you want to do on paper

– Start out by writing a Sentence or two describing what Start out by writing a Sentence or two describing what the goal of the project isthe goal of the project is

– Then together work on figuring out what fields will be Then together work on figuring out what fields will be necessary if there are any what information is required necessary if there are any what information is required to be in the field if any(validations) and whether a to be in the field if any(validations) and whether a calculation is necessarycalculation is necessary

– You may find it helpful to draw out rough sketches of You may find it helpful to draw out rough sketches of what the layouts are going to look likewhat the layouts are going to look like

– Don’t forget to write out in English what your scripts Don’t forget to write out in English what your scripts will do.will do.

AdviceAdvice

– Utilize the message board, if you’re having a problem Utilize the message board, if you’re having a problem figuring something out check the message board, if figuring something out check the message board, if there is nothing relevant there then post.there is nothing relevant there then post.

– If you have completed a problem and see a question If you have completed a problem and see a question related to it feel free to give the user a hint or explain a related to it feel free to give the user a hint or explain a concept, just don’t post your solution =)concept, just don’t post your solution =)

– I will jump in where necessary. I will jump in where necessary.

– Good luck.Good luck.

– There is no firm due date on this project (probably the There is no firm due date on this project (probably the last day of class), I reserve the right to add to the last day of class), I reserve the right to add to the definition it as we learn more material.definition it as we learn more material.