Ex450 - Baseball Team








Background: Hierarchy, Views
Related: Examples, Ex001, Ex015, Ex060

Description:
This example stores baseball team members.
Each person can have multiple roles, different attributes, multiple values
and players can belong to multiple teams. More specifically:
Each person has one or more roles (manager, coach, player).
Each person has an address comprised of street, city, state and zip.
Persons may have phones, faxes and email addresses.
Players have a position, player#, batting average and birthdate.
Players belong to one or more teams (astros and rangers).

Descriptions of Figures:
Fig 1 - Top-level db items.
Fig 2 - A player and his attributes.
Fig 3 - Players in teams astros and rangers.
Fig 4 - Persons in grid view.
Fig 5 - Managers in grid view.
Fig 6 - Players in grid view.
Fig 7 - Addresses in grid view.

Details:
1. Little Johnny and John Smith live at same address.
2. Little Ricky and Richard Davis live at same address.
3. Richard Davis is both a coach and a manager.
4. Little Johnny is on both teams.
5. John Smith has multiple phone numbers.


NLI Script

(; Create a db items)
(new 'person)
(new 'manager)
(new 'coach)
(new 'player)

(new 'address)
(new 'street)
(new 'city)
(new 'state)
(new 'zip)
(new 'phone)
(new 'fax)
(new 'email)

(new 'team)
(new 'fieldPos)
(new 'player#)
(new 'batAvg)
(new 'birthdate)

(; Create an address)
(new)
(set  address instance (it))
(set+ (it) street (set '123 'main 'st))
(set+ (it) city 'houston)
(set+ (it) state 'texas)
(set+ (it) zip '73038)

(; Create an address)
(new)
(set  address instance (it))
(set+ (it) street (set '456 'walnut 'ave))
(set+ (it) city 'dallas)
(set+ (it) state 'texas)
(set+ (it) zip '70223)

(; Create an address)
(new)
(set  address instance (it))
(set+ (it) street (set '789 'pecan 'dr))
(set+ (it) city (set 'el 'paso))
(set+ (it) state 'texas)
(set+ (it) zip '75050)

(; Create an address)
(new)
(set  address instance (it))
(set+ (it) street (set '213 'hemlock 'ct))
(set+ (it) city 'austin)
(set+ (it) state 'texas)
(set+ (it) zip '77979)

(; Create an address)
(new)
(set  address instance (it))
(set+ (it) street (set '617 'murdock 'rd))
(set+ (it) city 'lubbock)
(set+ (it) state 'texas)
(set+ (it) zip '79212)

(; Create an address)
(new)
(set  address instance (it))
(set+ (it) street (set '212 'kirkwood 'st))
(set+ (it) city 'amarillo)
(set+ (it) state 'texas)
(set+ (it) zip '78124)

(; Create an address)
(new)
(set  address instance (it))
(set+ (it) street (set '418 'dove 'ln))
(set+ (it) city 'austin)
(set+ (it) state 'texas)
(set+ (it) zip '77979)

(; Create an address)
(new)
(set  address instance (it))
(set+ (it) street (set '912 'blackwood 'rd))
(set+ (it) city 'dallas)
(set+ (it) state 'texas)
(set+ (it) zip '70223)

(; Create an address)
(new)
(set  address instance (it))
(set+ (it) street (set '690 'birchwood 'ct))
(set+ (it) city 'houston)
(set+ (it) state 'texas)
(set+ (it) zip '73038)


(; Create a person/player named johnny smith)
(new  (set 'johnny 'smith) 'person 'player)
(set+ (it) fieldPos 'pitcher)
(set+ (it) player# '34)
(set+ (it) batAvg '0.36)
(set+ (it) birthdate '7/12/89)
(set  (it) address (and (get address instance *)
                        (get * street (. '123 'main 'st))))
(set+ (it) phone '234-4554)
(set+ (it) email 'johnny@disney.com)

(; Create a person/manager named john smith)
(new  (set 'john 'smith) 'person 'manager)
(set  (it) address (and (get address instance *)
                        (get * street (. '123 'main 'st))))
(set+ (it) phone '234-4554)
(set+ (it) phone '387-2222)
(set+ (it) fax '333-4444)
(set+ (it) email 'john@ibm.com)

(; Create a person/manager named richard davis)
(new  (set 'richard 'davis) 'person 'manager)
(set  coach instance (it))
(set  (it) address (and (get address instance *)
                        (get * street (. '456 'walnut 'ave))))
(set+ (it) phone '876-3767)
(set+ (it) fax '666-7777)
(set+ (it) email 'rdavis@gm.com)

(; Create a person/player named rick davis)
(new  (set 'ricky 'davis) 'person 'player)
(set+ (it) fieldPos 'catcher)
(set+ (it) player# '15)
(set+ (it) batAvg '0.23)
(set+ (it) birthdate '3/26/88)
(set  (it) address (and (get address instance *)
                        (get * street (. '456 'walnut 'ave))))
(set+ (it) phone '876-3767)
(set+ (it) email 'ricky@disney.com)

(; Create a person/player named jimmy lee)
(new  (set 'jimmy 'lee) 'person 'player)
(set+ (it) fieldPos (set 'first 'base))
(set+ (it) player# '63)
(set+ (it) batAvg '0.15)
(set+ (it) birthdate '8/14/87)
(set  (it) address (and (get address instance *)
                        (get * street (. '789 'pecan 'dr))))
(set+ (it) phone '867-3793)

(; Create a person/player named timmy locke)
(new  (set 'timmy 'locke) 'person 'player)
(set+ (it) fieldPos (set 'second 'base))
(set+ (it) player# '76)
(set+ (it) batAvg '0.32)
(set+ (it) birthdate '5/23/88)
(set  (it) address (and (get address instance *)
                        (get * street (. '213 'hemlock 'ct))))
(set+ (it) phone '808-3387)
(set+ (it) email 'timmy@disney.com)

(; Create a person/player named jenny clark)
(new  (set 'jenny 'clark) 'person 'player)
(set+ (it) fieldPos (set 'third 'base))
(set+ (it) player# '88)
(set+ (it) batAvg '0.34)
(set+ (it) birthdate '1/19/88)
(set  (it) address (and (get address instance *)
                        (get * street (. '617 'murdock 'rd))))
(set+ (it) phone '867-9873)

(; Create a person/player named jackie berg)
(new  (set 'jackie 'berg) 'person 'player)
(set+ (it) fieldPos (set 'short 'stop))
(set+ (it) player# '12)
(set+ (it) batAvg '0.26)
(set+ (it) birthdate '3/27/89)
(set  (it) address (and (get address instance *)
                        (get * street (. '212 'kirkwood 'st))))

(; Create a person/player named billy ledman)
(new  (set 'billy 'ledman) 'person 'player)
(set+ (it) fieldPos (set 'left 'field))
(set+ (it) player# '47)
(set+ (it) batAvg '0.17)
(set+ (it) birthdate '9/12/88)
(set  (it) address (and (get address instance *)
                        (get * street (. '418 'dove 'ln))))
(set+ (it) phone '280-3998)
(set+ (it) email 'billy@disney.com)

(; Create a person/player named bobby brown)
(new  (set 'bobby 'brown) 'person 'player)
(set+ (it) fieldPos (set 'right 'field))
(set+ (it) player# '54)
(set+ (it) batAvg '0.29)
(set+ (it) birthdate '4/15/87)
(set  (it) address (and (get address instance *)
                        (get * street (. '912 'blackwood 'rd))))

(; Create a person/player named suzie harper)
(new  (set 'suzie 'harper) 'person 'player)
(set+ (it) fieldPos (set 'center 'field))
(set+ (it) player# '95)
(set+ (it) batAvg '0.30)
(set+ (it) birthdate '7/22/88)
(set  (it) address (and (get address instance *)
                        (get * street (. '690 'birchwood 'ct))))
(set+ (it) phone '880-3796)
(set+ (it) email 'suzie@barbie.com)


(; Create a verb named member that leads down hierarchy)
(new 'member 'verb)
(set member leads down)

(; Create a team named astros)
(new 'astros 'team)

(; Create astro members)
(set astros member (. 'johnny 'smith))
(set astros member (. 'ricky 'davis))
(set astros member (. 'jimmy 'lee))
(set astros member (. 'timmy 'locke))
(set astros member (. 'billy 'ledman))
(set astros member (. 'bobby 'brown))


(; Create a team named rangers)
(new 'rangers 'team)

(; Create ranger members)
(set rangers member (. 'johnny 'smith))
(set rangers member (. 'jenny 'clark))
(set rangers member (. 'jackie 'berg))
(set rangers member (. 'suzie 'harper))

Notes:

Download Database:
Ex450.zip (40 KB)
The creation of rolex replica the watch is inspired by the retro and elegant money of rolex replica watches the brand's round watch. The chronograph is omega replica simple and stylish, with the line features of rolex replica uk the watch series.

CM ©2000-2007